pyRdfa3 is a Python library that functions as an RDFa 1.1 distiller and parser. It can extract RDFa 1.1 (and, if properly configured, RDFa 1.0) from various document types including (X)HTML, SVG, and general XML. The library outputs either serialized RDF graphs or an RDFLib Graph object. The current version is 3.6.5. While the original maintainer has archived the primary GitHub repository, the 3.6.5 version is now built and maintained under a new GitHub Pages project, suggesting a community-driven or less frequent release cadence going forward.
pip install pyRdfa3Verified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `pyRdfa` to parse RDFa content from a source (a local HTML file in this case) and either obtain a serialized RDF string (defaulting to Turtle) or an RDFLib Graph object.
Monitor the new GitHub Pages project (prrvchr.github.io/pyrdfa3) for updates and be aware of potential delays in bug fixes or new features. Consider contributing to the project if active maintenance is critical for your use case.
Ensure your environment uses Python 3.8 or a newer compatible version.
Consult the RDFa 1.1 specifications (Core, XHTML+RDFa, HTML+RDFa) and the `pyRdfa` documentation to understand the exact parsing behavior for different RDFa versions. Ensure your markup explicitly uses `@version` if mixing RDFa 1.0 and 1.1 concepts.
Use a recent version of RDFLib (>=7.0.0 as recommended by pyrdfa3). If encountering serialization issues or needing JSON-LD, ensure `pyRdfaExtras` is installed or verify `rdflib_jsonld` compatibility with your RDFLib version.
Avoid using these scripts directly. Implement similar functionality by calling the `pyRdfa` library methods directly within your Python 3 application.
Ensure you are calling the `pyRdfa` class. Correct: `from pyRdfa import pyRdfa; distiller = pyRdfa()`. Incorrect: `import pyRdfa; distiller = pyRdfa()`.
Install the package using pip: `pip install pyRdfa3`. If it's already installed, verify your Python environment's PYTHONPATH.
Ensure you have a compatible `rdflib` version (>=7.0.0). If the issue persists, try installing `pyRdfaExtras` if it's explicitly required by your `pyrdfa3` version for JSON-LD, or `pip install rdflib-jsonld` if using an older RDFLib that doesn't include it.