extruct
Extract embedded metadata from HTML markup
What it is and what it does
extruct is a metadata extraction library that parses HTML documents and pulls out structured data embedded in standard formats. It handles W3C Microdata (including schema.org), JSON-LD, Microformats, Open Graph tags, RDFa, and Dublin Core metadata—all through a single unified interface. You pass it an HTML string and optional base URL, and it returns a dictionary keyed by format type, each containing the extracted data.
The library wraps several specialized parsers (lxml, rdflib, mf2py, pyrdfa3) and HTML utilities (w3lib, html-text, jstyleson) to normalize their output. It's commonly used in web scraping, SEO analysis, and data integration pipelines where you need to reliably extract metadata that content publishers have embedded for search engines, social media, or semantic web applications.
Use it for:
- Extract schema.org Microdata from e-commerce product pages to build product catalogs
- Parse Open Graph tags from web pages for social media link previews and metadata
- Harvest JSON-LD structured data from news articles and blog posts for content indexing
- Extract Microformats from personal websites and social profiles for contact/event data
- Build semantic web applications by parsing RDFa annotations from HTML documents
- Aggregate Dublin Core metadata from institutional or library websites
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Extracts structured metadata from HTML markup in multiple formats: Microdata, JSON-LD, Microformats, Open Graph, RDFa, and Dublin Core.
Yes. extruct is actively maintained, has no known vulnerabilities, supports current Python versions (3.8–3.12), and installs with low friction. It solves a real problem—unified extraction of multiple metadata formats—that would otherwise require juggling separate parsers. The permissive license and 971 repository stars indicate solid community adoption. Install it if you need to reliably extract structured metadata from HTML in production or research contexts.
Install
extruct on PyPI
pip
pip install extructuv
uv add extructpoetry
poetry add extructInstalling extruct
Before you install
Low install friction with a pure-Python wheel. Active maintenance with recent commits and 971 repository stars. Supports Python 3.8 through 3.12.
License in practice
Permissive license allows commercial and private use without restriction.
Quickstart
pip install extruct
import extruct
from w3lib.html import get_base_url
html = '<html>...</html>'
base_url = 'https://example.com'
data = extruct.extract(html, base_url=base_url)
Verify before relying
- Performance characteristics when processing large HTML documents or batch operations
- Specific version compatibility matrix for each metadata format parser (mf2py, rdflib, pyrdfa3)
- Whether experimental RDFa support is production-ready
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 8 — lxml, lxml-html-clean, rdflib, pyrdfa3, mf2py, w3lib, html-text, jstyleson |
| Maintenance | actively maintained — 644 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 659,409/month — #5,463 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: extruct-0.18.0-py2.py3-none-any.whl
Keywords: extruct
Tags
More HTML packages
MarkupSafe provides a text object that escapes…
permissive · top 100 on PyPI
Jinja2Jinja2 is a templating engine that renders…
permissive · top 100 on PyPI
beautifulsoup4Beautiful Soup parses HTML and XML documents…
permissive · top 100 on PyPI
lxmllxml provides Python bindings to libxml2 and…
permissive · top 1,000 on PyPI
docutilsDocutils converts plaintext documentation in…
unclear · top 1,000 on PyPI
MarkdownConverts Markdown text to HTML using a Python…
permissive · top 1,000 on PyPI
linkpreviewExtracts preview metadata (title, description,…
permissive · top 15,000 on PyPI
mf2pymf2py parses HTML documents to extract…
permissive · top 15,000 on PyPI
PyLDPyLD is a Python implementation of the JSON-LD…
permissive · top 15,000 on PyPI
pyrdfa3Parses RDFa markup embedded in HTML documents…
unclear · top 15,000 on PyPI
recipe-scrapersExtracts structured recipe data (ingredients,…
permissive · top 15,000 on PyPI
rdflib-jsonldProvides JSON-LD parsing and serialization for…
permissive · top 15,000 on PyPI
provImplements the W3C PROV Data Model in Python,…
permissive · top 15,000 on PyPI
rdflibRDFLib is a Python library for parsing,…
permissive · top 1,000 on PyPI
sphinxext-opengraphSphinx extension that automatically generates…
permissive · top 15,000 on PyPI
SickleSickle is a lightweight Python client library…
permissive · top 15,000 on PyPI