python-microformats 0.3.5
tools for microformats production, consumption and analysis
IndieWeb,
microformats
Licensed: BSD 3-Clause "Modified" License
Provides: scripts ( mf )
● 44 tests passing in 1.231s
[microformats][0] 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 = 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> ... ''' >>> page = mf.parse(doc=doc, url=url)
# TODO >>> dict(page) # TODO >>> page.json
>>> card = page["items"][0] >>> card["type"] ['h-card'] >>> card["properties"] {'name': ['Alice'], 'url': ['https://alice.example']} >>> feed = page["items"][1] >>> feed["children"][0]["properties"]["name"] ['foo']
>>> mf.util.representative_card(page, url) {'name': ['Alice'], 'url': ['https://alice.example']} >>> mf.util.representative_feed(page, url)["items"][0]["name"] ['foo']
# TODO >>> page.representative_card # TODO {'name': ['Alice'], 'url': ['https://alice.example']} # TODO >>> page.representative_feed["items"][0]["name"] # TODO ['foo']
Based upon [mf2py
][1] and [mf2util
][2].
mf
Microformats utilities.
easyuri, bs4527
LLOC,
moderately maintainable
representative_card(mf2json: dict, source_url: str)
Return the representative card for given parsed document.
Package: microformats
Requires:
python >=3.8,<3.11
,
beautifulsoup4
,
easyuri
,
mf2py
,
txtint
Releases
git clone https://ragt.ag/code/projects/python-microformats.git