mf2py is a Python library for parsing Microformats data from HTML documents. It provides full support for microformats2, offers backwards-compatible support for microformats1, and includes experimental support for metaformats. The library is actively maintained, with version 2.0.1 being the latest release, and is part of the broader IndieWeb ecosystem.
pip install mf2pyVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to parse an HTML string containing microformats2 markup using `mf2py.parse()`. It returns a dictionary representing the microformats found. You can also parse directly from a URL.
Upgrade your Python environment to 3.8 or higher. If unable, pin mf2py to a version < 2.0 (e.g., `mf2py<2.0`).
Remove `img_with_alt=True` or `img_with_alt=False` from your `mf2py.parse()` or `mf2py.Parser()` calls. The functionality is now on by default.
Remove the `dict_class` argument from `mf2py.Parser()` instantiations. `mf2py` now consistently uses Python's built-in `dict`.
If you need to preserve the original BeautifulSoup document, consider creating a deep copy before passing it to `mf2py.parse()` or `mf2py.Parser()`.
Remove the `img_with_alt` parameter from `mf2py.parse()` or `mf2py.Parser()` calls. Image alt parsing is now enabled by default.
Use `python3 -m pip install mf2py` or ensure `python` correctly points to your desired Python 3 interpreter.
Run `pip install mf2py` to install the library.