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 = 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']
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.5.0.tar.gz
(13.5 kB
view hashes)
Built Distribution
Close
Hashes for microformats-0.5.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32783b2c5572698034c09bd02b301299281cb853bf05b916946f070eb88e1ddc |
|
MD5 | dad49f0119330c122bb8b59c0fc16682 |
|
BLAKE2b-256 | 5c5ca95e21245b157fffa6aa1145c0d6abb908197c9e3d858f80272bc353af32 |