tools for microformats production, consumption and analysis
Project description
microformats are the simplest way to openly publish contacts, events, reviews, recipes, and other structured information on the web.
>>> import mf
>>> url = "https://alice.example"
>>> doc = mf.parse(doc=f'''
... <p class=h-card><a href={url}>Alice</a></p>
... <ul class=h-feed>
... <li class=h-entry>foo
... <li class=h-entry>bar
... </ul>
... ''', url=url)
# TODO >>> dict(doc)
# TODO >>> doc.json
>>> card = doc["items"][0]
>>> card["type"]
['h-card']
>>> card["properties"]
{'name': ['Alice'], 'url': ['https://alice.example']}
>>> feed = doc["items"][1]
>>> feed["children"][0]["properties"]["name"]
['foo']
>>> mf.util.representative_card(doc, url)
{'name': ['Alice'], 'url': ['https://alice.example']}
>>> mf.util.representative_feed(doc, url)["items"][0]["name"]
['foo']
# TODO >>> doc.representative_card
# TODO {'name': ['Alice'], 'url': ['https://alice.example']}
# TODO >>> doc.representative_feed["items"][0]["name"]
# TODO ['foo']
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
microformats-0.3.4.tar.gz
(27.2 kB
view hashes)
Built Distribution
Close
Hashes for microformats-0.3.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d29e3d0aa94a03bf25d45ae4feaba01da517b778e2f9b3494dd80ea954f7ba6 |
|
MD5 | 64dbc7ee8d7dcdfae3fa17e9e98d3012 |
|
BLAKE2b-256 | 25beeeb4b7c3bf327b3f35ea0b745642aa2a3933b45448b8cdff6f79eacf5caf |