{"id":22267841,"url":"https://github.com/microformats/mf2py","last_synced_at":"2025-05-16T03:06:09.256Z","repository":{"id":14217672,"uuid":"16924500","full_name":"microformats/mf2py","owner":"microformats","description":"Microformats2 parser written in Python","archived":false,"fork":false,"pushed_at":"2024-10-30T18:48:59.000Z","size":1769,"stargazers_count":106,"open_issues_count":4,"forks_count":28,"subscribers_count":18,"default_branch":"main","last_synced_at":"2025-05-12T04:51:59.101Z","etag":null,"topics":["indieweb","mf2","microformats","microformats2","parser","python","python3"],"latest_commit_sha":null,"homepage":"http://microformats.github.io/mf2py/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/microformats.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-02-17T19:49:38.000Z","updated_at":"2025-03-06T05:37:59.000Z","dependencies_parsed_at":"2023-12-08T02:24:53.615Z","dependency_job_id":"b16ddc55-c451-425d-b572-4c51213ce500","html_url":"https://github.com/microformats/mf2py","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microformats%2Fmf2py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microformats%2Fmf2py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microformats%2Fmf2py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microformats%2Fmf2py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/microformats","download_url":"https://codeload.github.com/microformats/mf2py/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254459088,"owners_count":22074605,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["indieweb","mf2","microformats","microformats2","parser","python","python3"],"created_at":"2024-12-03T11:09:14.547Z","updated_at":"2025-05-16T03:06:04.248Z","avatar_url":"https://github.com/microformats.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![mf2py banner](https://microformats.github.io/mf2py/banner.png)\n\n[![version](https://badge.fury.io/py/mf2py.svg?)](https://badge.fury.io/py/mf2py)\n[![downloads](https://img.shields.io/pypi/dm/mf2py)](https://pypistats.org/packages/mf2py)\n[![license](https://img.shields.io/pypi/l/mf2py?)](https://github.com/microformats/mf2py/blob/main/LICENSE)\n[![python-version](https://img.shields.io/pypi/pyversions/mf2py)](https://badge.fury.io/py/mf2py)\n\n## Welcome 👋\n\n`mf2py` is a Python [microformats](https://microformats.org/wiki/microformats) parser with full support for `microformats2`, backwards-compatible support for `microformats1` and experimental support for `metaformats`.\n\n## Installation 💻\n\nTo install `mf2py` run the following command:\n\n```bash\n$ pip install mf2py\n\n```\n\n## Quickstart 🚀\n\nImport the library:\n\n```pycon\n\u003e\u003e\u003e import mf2py\n\n```\n\n### Parse an HTML Document from a file or string\n\n```pycon\n\u003e\u003e\u003e with open(\"test/examples/eras.html\") as fp:\n...     mf2json = mf2py.parse(doc=fp)\n\u003e\u003e\u003e mf2json\n{'items': [{'type': ['h-entry'],\n            'properties': {'name': ['Excited for the Taylor Swift Eras Tour'],\n                           'author': [{'type': ['h-card'],\n                                       'properties': {'name': ['James'],\n                                                      'url': ['https://example.com/']},\n                                       'value': 'James',\n                                       'lang': 'en-us'}],\n                           'published': ['2023-11-30T19:08:09'],\n                           'featured': [{'value': 'https://example.com/eras.jpg',\n                                         'alt': 'Eras tour poster'}],\n                           'content': [{'value': \"I can't decide which era is my favorite.\",\n                                        'lang': 'en-us',\n                                        'html': \"\u003cp\u003eI can't decide which era is my favorite.\u003c/p\u003e\"}],\n                           'category': ['music', 'Taylor Swift']},\n            'lang': 'en-us'}],\n 'rels': {'webmention': ['https://example.com/mentions']},\n 'rel-urls': {'https://example.com/mentions': {'text': '',\n                                               'rels': ['webmention']}},\n 'debug': {'description': 'mf2py - microformats2 parser for python',\n           'source': 'https://github.com/microformats/mf2py',\n           'version': '2.0.1',\n           'markup parser': 'html5lib'}}\n\n```\n\n```pycon\n\u003e\u003e\u003e mf2json = mf2py.parse(doc=\"\u003ca class=h-card href=https://example.com\u003eJames\u003c/a\u003e\")\n\u003e\u003e\u003e mf2json[\"items\"]\n[{'type': ['h-card'],\n  'properties': {'name': ['James'],\n                 'url': ['https://example.com']}}]\n\n```\n\n### Parse an HTML Document from a URL\n\n```pycon\n\u003e\u003e\u003e mf2json = mf2py.parse(url=\"https://events.indieweb.org\")\n\u003e\u003e\u003e mf2json[\"items\"][0][\"type\"]\n['h-feed']\n\u003e\u003e\u003e mf2json[\"items\"][0][\"children\"][0][\"type\"]\n['h-event']\n\n```\n\n## Experimental Options\n\nThe following options can be invoked via keyword arguments to `parse()` and `Parser()`.\n\n### `expose_dom`\n\nUse `expose_dom=True` to expose the DOM of embedded properties.\n\n### `metaformats`\n\nUse `metaformats=True` to include any [metaformats](https://microformats.org/wiki/metaformats)\nfound.\n\n### `filter_roots`\n\nUse `filter_roots=True` to filter known conflicting user names (e.g. Tailwind).\nOtherwise provide a custom list to filter instead.\n\n## Advanced Usage\n\n`parse` is a convenience function for `Parser`. More sophisticated behaviors are\navailable by invoking the parser object directly.\n\n```pycon\n\u003e\u003e\u003e with open(\"test/examples/festivus.html\") as fp:\n...     mf2parser = mf2py.Parser(doc=fp)\n\n```\n\n#### Filter by Microformat Type\n\n```pycon\n\u003e\u003e\u003e mf2json = mf2parser.to_dict()\n\u003e\u003e\u003e len(mf2json[\"items\"])\n7\n\u003e\u003e\u003e len(mf2parser.to_dict(filter_by_type=\"h-card\"))\n3\n\u003e\u003e\u003e len(mf2parser.to_dict(filter_by_type=\"h-entry\"))\n4\n\n```\n\n#### JSON Output\n\n```pycon\n\u003e\u003e\u003e json = mf2parser.to_json()\n\u003e\u003e\u003e json_cards = mf2parser.to_json(filter_by_type=\"h-card\")\n\n```\n\n## Breaking Changes in `mf2py` 2.0\n\n- Image `alt` support is now on by default.\n\n## Notes 📝\n\n- If you pass a BeautifulSoup document it may be modified.\n- A hosted version of `mf2py` is available at [python.microformats.io](https://python.microformats.io).\n\n## Contributing 🛠️\n\nWe welcome contributions and bug reports via GitHub.\n\nThis project follows the [IndieWeb code of conduct](https://indieweb.org/code-of-conduct). Please be respectful of other contributors and forge a spirit of positive co-operation without discrimination or disrespect.\n\n## License 🧑‍⚖️\n\n`mf2py` is licensed under an MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicroformats%2Fmf2py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicroformats%2Fmf2py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicroformats%2Fmf2py/lists"}