trafilatura-rs
A Rust port of trafilatura's extraction that returns the same output, byte for byte, as trafilatura 1.11.0 or 2.3.1, using 8 to 11 times less CPU for text extraction.
Install
pip install "trafilatura-rs[trafilatura]" # trafilatura 1.11.0
pip install "trafilatura-rs[trafilatura2]" # trafilatura 2.3.1
trafilatura-rs reproduces whichever of the two is installed. The extras pin the versions it is checked against:
| Package | [trafilatura] |
[trafilatura2] |
|---|---|---|
| trafilatura | 1.11.0 | 2.3.1 |
| lxml | 6.1.3 | 6.1.3 |
| htmldate (metadata) | 1.11.0 | 1.11.0 or newer, via trafilatura 2.3.1 |
htmldate 1.11.0 and trafilatura 2.3.1 require lxml 6.1.3 or newer, so the extras install 6.1.3. Metadata runs in Rust with htmldate 1.11.0 only (see Exactness). Wheels are built for Linux (glibc and musl, x86_64 and aarch64), macOS (x86_64 and arm64) and Windows (x64 and arm64), Python 3.10+, with libxml2 statically linked.
Quickstart
Run existing code unchanged:
TRAFILATURA_RS=1 python my_script.py # or: python -m trafilatura_rs my_script.py
Or in code:
import trafilatura_rs
trafilatura_rs.install() # patches trafilatura, including copies imported earlier
from trafilatura_rs import extract # or import the drop-in directly; same signature
Calls trafilatura-rs covers run in Rust; every other call runs Python trafilatura as before. That includes calls
made inside other libraries, such as datatrove's Trafilatura step (or use
datatrove-rs), and trafilatura's command line.
trafilatura_rs.supports(**kwargs) says whether an extract call runs in Rust; supports_bare_extraction,
supports_baseline, supports_html2txt, supports_extract_metadata and supports_find_date do the same for the
other functions. trafilatura_rs.engine() returns the trafilatura version being reproduced.
What runs in Rust
extract()on str or bytes, withoutput_formattxt, markdown, json, xml, html or csv, with or without metadata, comments,include_linksandinclude_images, and the usual options (favor_precision,favor_recall,no_fallback/fast,include_tables,deduplicate,url,options=Extractor(...), config files, blacklists,prune_xpath,date_extraction_params), andtarget_languagewith txt and json (a port of py3langid's classifier that answers only when float32 rounding can't change the result; close calls go to Python)- metadata: title, author, date (a port of htmldate's
find_date, with native ports of the dateutil and dateparser calls it makes; rare strings go to Python), sitename, categories, tags, license, JSON-LD html2txt,baseline,extract_metadata,bare_extraction(also with links, images anddeduplicate) and htmldate'sfind_date- trafilatura's command line, which calls
extractwith bytes
Python trafilatura still runs:
target_languagewith other outputs or with links/images- lxml trees with trafilatura 1.11.0 (it changes the caller's tree; 2.3.1 trees run in Rust) and other non-str/bytes input
- 2.3.1's
deduplicategiven a scopedLRUCache - metadata on Python 3.10
- every call when the installed versions don't match (see below)
With deduplicate=True, calls that run in Python share trafilatura-rs's deduplication cache, so outputs depend on
earlier pages exactly as in trafilatura.
Which configurations each output is verified for, and the details per function: docs/coverage.md.
Exactness
Every covered configuration is checked page by page against trafilatura 1.11.0 and 2.3.1 on 10,666 Common Crawl pages, comparing the final output and per-stage tree hashes; any difference is treated as a bug. The output matches because the parser does: trafilatura-rs statically links libxml2 2.14.6, the version lxml 6.1.3 bundles, with the same parsing options (PATCHES.md). Documents the port declines inside a covered call rerun in Python.
Three version guards keep results exact when other packages are installed:
| Guard | Pins | When the installed version differs |
|---|---|---|
REPRODUCES |
(trafilatura, lxml) pairs: 1.11.0 or 2.3.1 with lxml 6.0.0 to 6.1.3 | every call runs Python; install() warns and patches nothing |
REPRODUCES_METADATA |
htmldate 1.11.0 | metadata calls and find_date run Python |
REPRODUCES_DATES (trafilatura_rs._versions) |
dateparser 1.5.0, python-dateutil 4.0.0 | the native date parsers are off; htmldate's dateparser and dateutil calls run in Python |
trafilatura's output under each lxml 6.0.x and 6.1.x release equals its output under 6.1.3 on the full corpus,
which is why REPRODUCES accepts them. Metadata also needs Python 3.11+. The differences between the two trafilatura
versions: docs/trafilatura-2x-diff.md,
docs/trafilatura-23-diff.md.
rs-trafilatura is a different project: an independent extractor inspired by trafilatura rather than a port. With datatrove's call its output equals trafilatura 1.11.0's on 171 of the 10,666 pages.
Speed
CPU time per page, Python trafilatura divided by trafilatura-rs, single thread. The first two rows are fresh runs on the full corpus, median of 3 (docs/benchmarks.md has the times, instruction counts and machine load). The other rows are the results recorded in the pull request that added them.
| Call | 1.11.0 | 2.3.1 | Pages | Source |
|---|---|---|---|---|
datatrove's call: favor_precision=True, include_comments=False, deduplicate=True |
11.0x | 8.3x | 10,666 | benchmarks |
extract(html) |
8.8x | 8.5x | 10,666 | benchmarks |
output_format="markdown" |
8.5x | 12.9x | 3,000 | #7 |
command line (bytes, options=Extractor()) |
8.2x | 9.5x | 3,000 | #7 |
with_metadata=True, url=..., include_comments=False |
4.7x | 4.9x | 3,000 | #16 |
output_format="json", with_metadata=True, include_comments=False, balanced / precision |
5.4x / 6.0x | 4.4x / 6.9x | 3,000 | #16 |
output_format xml, html, csv (include_comments=False) |
9.9–10.4x | 8.4–9.2x | 3,000 | #13 |
include_links / include_images, without metadata |
7.2–9.8x | 7.4–8.4x | 3,000 | #13 |
deduplicate=True, with_metadata=True: txt with favor_precision, xml |
7.1–7.5x | 7.1–7.2x | 3,000 | benchmarks |
bare_extraction(html, include_links=True, ...), alone and with images and metadata |
6.2–6.4x | 6.4–7.0x | 3,000 | benchmarks |
bare_extraction(html, deduplicate=True), favor_precision / with metadata |
8.2x / 5.9x | 7.3x / 6.5x | 3,000 | benchmarks |
bare_extraction(html), each focus, with and without comments |
6.8–10.1x | 6.2–8.0x | 10,666 | #10 |
bare_extraction(html, with_metadata=True, url=...) |
2.4–3.2x | 3.0–3.6x | 10,666 | #10 |
html2txt(html) / baseline(html) |
2.2x | 4.2–4.3x | 10,666 | #10 |
extract_metadata(html), with and without default_url |
1.6–1.7x | 1.9–2.0x | 10,666 | #10 |
htmldate.find_date(html), with and without url |
2.0–2.6x | 2.0–2.6x | 10,666 | #10 |
The bare_extraction speedups from #10 leave out the 29 to 74 pages per configuration that rerun in Python; the
3,000-page ones include them.
Contributing
Development setup, the parity harness, benchmarks and releasing: CONTRIBUTING.md.
License
Apache-2.0, like trafilatura. Vendored libxml2 is MIT-licensed; win-iconv (Windows builds) is public domain. trafilatura-rs is an independent project and is not affiliated with the trafilatura authors.
Metadata
Release files for trafilatura-rs 0.1.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| trafilatura_rs-0.1.11.tar.gz | 3.0 MB | With provenance | Details for trafilatura_rs-0.1.11.tar.gz |
Built distributions (wheels)
Total release size: 27.7 MB
Release files / trafilatura_rs-0.1.11.tar.gz
| Download URL | trafilatura_rs-0.1.11.tar.gz |
|---|---|
| Size | 3.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c9b6ef736682c61e795f51f70c886d9f85506b0844e4b7fbbb1031db654350a6
|
|
BLAKE2b-256 checksum How to use checksums |
124071b05bfbdd1088e2efd6ea55e840072929bedf33c6e6f16c5323d222cf26
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 17, 2026.
Transparency logRelease files / trafilatura_rs-0.1.11-cp310-abi3-win_arm64.whl
| Download URL | trafilatura_rs-0.1.11-cp310-abi3-win_arm64.whl |
|---|---|
| Size | 3.1 MB |
| Tags | CPython 3.10 Windows ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
bb84388ef72e0a40acf6046c30e2b54444c279a1b0142a5ffc50d516aa5c90a4
|
|
BLAKE2b-256 checksum How to use checksums |
d63862ffb9fde136f353496f68be94658fa7a94dd704ee539eeb274b43007f73
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 17, 2026.
Transparency logRelease files / trafilatura_rs-0.1.11-cp310-abi3-win_amd64.whl
| Download URL | trafilatura_rs-0.1.11-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
f6ee25609ed55dbb5ba43d9293411debf6cca09065b93887c0b2283af8e154fd
|
|
BLAKE2b-256 checksum How to use checksums |
76a164198574047124b4e279d61b9e4898d249662415f8fa14975949e5c54bb7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 17, 2026.
Transparency logRelease files / trafilatura_rs-0.1.11-cp310-abi3-musllinux_1_2_x86_64.whl
| Download URL | trafilatura_rs-0.1.11-cp310-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.10 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
bb072180cc160e6d681d46cb4b00deebeb57d20bb22f10f7098c82b9890e4e64
|
|
BLAKE2b-256 checksum How to use checksums |
d607b3aacdb376dcce6ba74a7db7dab5f821c8226dc90556842fd611f49f9129
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 17, 2026.
Transparency logRelease files / trafilatura_rs-0.1.11-cp310-abi3-musllinux_1_2_aarch64.whl
| Download URL | trafilatura_rs-0.1.11-cp310-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 3.2 MB |
| Tags | CPython 3.10 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
eb74f117ee0828f026a8c56b539ec3498e5d1d48800f0377c5093983d690c0c4
|
|
BLAKE2b-256 checksum How to use checksums |
a2aafde87d0858670ef0df0909ecb8f339b7343556d8680ed5b7b3828436af16
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 17, 2026.
Transparency logRelease files / trafilatura_rs-0.1.11-cp310-abi3-manylinux_2_28_x86_64.whl
| Download URL | trafilatura_rs-0.1.11-cp310-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 3.1 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
a565086c0cfd673091175e73ab638ccdeef567b6f62ed20b706f650af2f68d27
|
|
BLAKE2b-256 checksum How to use checksums |
c2fd236c5d1db47805b60cc2c3340b5ced181141895c5027ccc81fe524a1f75f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 17, 2026.
Transparency logRelease files / trafilatura_rs-0.1.11-cp310-abi3-manylinux_2_28_aarch64.whl
| Download URL | trafilatura_rs-0.1.11-cp310-abi3-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 3.0 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
7ed743067ac6a1fdcb55d540ed080d4c5fbcbfb54d248d1f1a2cecb9b146a22a
|
|
BLAKE2b-256 checksum How to use checksums |
f53132beecf640d27295890f32d6f9f02979a966d8769cdbb8a6b0c5b3c2ec07
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 17, 2026.
Transparency logRelease files / trafilatura_rs-0.1.11-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | trafilatura_rs-0.1.11-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 2.9 MB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
723bc39fbdaf565df626247abf231dafd52776eb2d8c16b76e8a120c9ad215b4
|
|
BLAKE2b-256 checksum How to use checksums |
6c9fac2009beeadc70e60624ff6738c85457e07eea67ac8d190b4093ee5ed05f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 17, 2026.
Transparency logRelease files / trafilatura_rs-0.1.11-cp310-abi3-macosx_10_12_x86_64.whl
| Download URL | trafilatura_rs-0.1.11-cp310-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 3.0 MB |
| Tags | CPython 3.10 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
9cc336d49fa3bf526fe96e44b28c43cf1b360ac0a12e07bcc05d3f3c1f34e6ef
|
|
BLAKE2b-256 checksum How to use checksums |
45efcd0eb65d430c2648480a96d3b5a3d7fe1b685621ee21c4e6849a41e54106
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 17, 2026.
Transparency logSecurity for trafilatura-rs 0.1.11
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.
Full provenance
All 9 files in this release have been uploaded with provenance metadata.
Attestation for trafilatura_rs-0.1.11.tar.gz
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 Nov 17, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.