Trafilatura Core
Also available as:Online playground | npm package CLI & lib | Source code on GitHubDocsGetting started | Python library helpSocialStar us on GitHub | Follow us on GitHub |
Trafilatura Core extracts main content by removing boilerplate from HTML documents.
-
Two language versions — TypeScript and Python: available as a TypeScript library on npm and a Python library on PyPI.
-
Trafilatura Core is an open-source fork of the Python library Trafilatura, with go-trafilatura as a DOM translation aid.
-
The Core in its name means it is reduced to one task: extracting main content by removing boilerplate. An optional Source URL supplies metadata and image-resolution context; it is never fetched. Use Turndown for Markdown conversion and Markdownee for crawling live websites.
This package provides the native Python library, with library APIs only. It returns cleaned HTML, diagnostics, and available page metadata; see the Python reference for language differences.
Install and use
Requires Python 3.10 or newer:
pip install trafilaturacore
Save this as clean.py:
from trafilaturacore import clean
source = """<nav>Home</nav><article><h1>Reading saved pages</h1>
<p>Save the original HTML before cleaning a page. A local copy lets
you compare the extracted article with its navigation and footer.</p>
<p>Keep the source address beside the snapshot. It provides context
when relative image links need to be resolved after extraction.</p>
</article>"""
result = clean(source)
print(result.html)
python clean.py
The result prints the article heading and paragraphs without navigation.
clean() accepts a string or UTF-8 bytes. Its CleanResult has html,
messages, and optional metadata; aclean() accepts the same options
for async callers. Cancelling its await does not stop an already running worker.
Configure cleanup
Select precision, balanced (default), or recall for extraction;
keep cleans the whole document. Image, link, table, and user-comment handling
are independent. The Python reference
covers options, custom policies, async usage, resource limits, and errors.
Python uses lxml and nh3. Parsing, serialization, date/URL handling, custom configuration, CSS preservation, diagnostics, and limits can differ from the TypeScript library. Dependencies install separately; platforms without compatible dependency wheels need their build prerequisites.
Extraction is not a security boundary. Before rendering untrusted output, apply sanitization appropriate to your output context and a Content Security Policy. Remote links and images may remain.
Acknowledgements
- Trafilatura — original Python implementation by Adrien Barbaresi.
- go-trafilatura — Go port by Markus Mobius, used as a DOM translation aid.
See About for extraction lineage and scope.
Support
Report problems in the issue tracker.
License
Licensed under Apache-2.0. See the compact third-party notices.
Metadata
Release files for trafilaturacore 0.8.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| trafilaturacore-0.8.6-py3-none-any.whl | Python 3 | none | any | Details |
Release files / trafilaturacore-0.8.6-py3-none-any.whl
| Download URL | trafilaturacore-0.8.6-py3-none-any.whl |
|---|---|
| Size | 110.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8871e54f3bcfc486c64c79d2819027e3812e70fa424569184ac2cd2eed9d32a8
|
|
BLAKE2b-256 checksum How to use checksums |
856216d8bc54169bc5f1672b21cbe48f4466b24dcf1ee2d73caa2bedbb4c2904
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 30, 2026.
Transparency log