Skip to main content

trafilatura-rs

Byte-exact drop-in for trafilatura 1.11's extract() (txt output, include_comments=False), in Rust: same output, byte for byte, ~9x less CPU. Pinned to trafilatura 1.11.0 + lxml 6.1.3 / libxml2 2.14.6 (vendored and statically linked, see crates/libxml2-sys/PATCHES.md).

Not related to the rs-trafilatura package, which is a separate extractor with different output (exact on 171/10,666 pages, see Benchmark).

A port of trafilatura 2.2.0's pipeline (crates/trafilatura-rs/src/trafilatura2, diff in research/trafilatura-2x-diff.md) is verified by the harness but not exposed in Python yet.

Verified configs

trafilatura_rs.VERIFIED, each byte-identical to Python on the 10,666-doc corpus below ((favor_precision, favor_recall, include_tables, no_fallback)):

harness cfg args 1.11 final 2.2.0 final
fineweb favor_precision=True, deduplicate=True (datatrove) 10666/10666 10666/10666
balanced defaults 10666/10666 10666/10666
recall favor_recall=True 10666/10666 10666/10666
fast no_fallback=True 10666/10666 10666/10666
notables include_tables=False 10666/10666 10666/10666

Stage hashes: 1.11 (fineweb) 10666/10666; 2.2.0 balanced and fineweb 10666/10666. jusText and readability components: 10666/10666. Any other argument falls back to Python trafilatura.

Usage

pip install trafilatura-rs
import trafilatura_rs
trafilatura_rs.install()  # patches trafilatura.extract; covered calls run in Rust, others stay on Python
# e.g. datatrove's Trafilatura(favour_precision=True) now runs trafilatura-rs
trafilatura_rs.extract(html, favor_precision=True, deduplicate=True)   # direct; NotImplementedError if not covered

deduplicate=True keeps a process-global LRU like trafilatura's, so output depends on doc order; trafilatura_rs.reset_caches() clears it.

Dev setup (Linux)

Needs Rust, cmake, uv, perf. Corpus and references live outside the repo in $TRAFILATURA_RS_DATA (default /srv/agents/cache/trafilatura-rs-data).

tools/dev.sh setup     # .venv (py3.13: trafilatura 1.11, datatrove via .pth from $DATATROVE_SRC, rs-trafilatura)
                       # + .venv-t22 (trafilatura 2.2.0)
tools/dev.sh build     # cargo build --release (harness bins)
tools/dev.sh py        # maturin develop --release into .venv
tools/dev.sh test      # cargo test
tools/build_wheel.sh   # abi3 wheel in target/wheels (PGO=1 for profile-guided, via tools/pgo.sh)
pytest tests           # parity vs trafilatura on tests/fixtures (needs the wheel + `.[test]` pins; CI runs this)

Releases: .github/workflows/release.yml builds abi3 wheels (Linux x86_64/aarch64, macOS x86_64/arm64, Windows x64) and an sdist, smoke-tests each against trafilatura, and publishes to PyPI on a v* tag matching pyproject.toml's version.

Parity

tools/make_reference.sh   # exports docs.jsonl (first 10,666 URLFilter-passing HTML records of the WARC) and all
                          # Python references; REF_JOBS parallel, skips existing files (~50 CPU-min)
tools/parity.sh           # every job; or e.g. tools/parity.sh stages final:fineweb final2:recall
LIMIT=500 tools/parity.sh final:fineweb
tools/parity.sh show 123 txt          # diff one doc's stage (show2 for 2.2.0)
TRAFILATURA_RS_VERIFY_XPATH=1 tools/parity.sh final:fineweb   # cross-check fast-path XPaths against libxml2

Benchmark

tools/bench.sh [N] — trafilatura 1.11 via datatrove's call, the same call after trafilatura_rs.install(), and rs_trafilatura.extract(html, favor_precision=True, include_comments=False). Fresh process per run, same docs in the same order, single thread, engines alternated over ROUNDS (default 2). Reports per-doc CPU time (min over rounds) and perf stat user-space instructions net of a load-only baseline; never wall time (shared box). It also checks trafilatura-rs output == trafilatura output on every doc (the end-to-end check) and rs-trafilatura agreement.

Full corpus (10,666 docs), 2026-11-10, loaded 16-core box:

engine mean ms/doc p50 p99 Minstr/doc speedup (CPU / instr) output == trafilatura
trafilatura 1.11 17.93 11.19 110.83 261.7 1x —
trafilatura-rs 1.92 1.25 11.85 23.2 9.3x / 11.3x 10666/10666
rs-trafilatura 0.1.1 12.24 7.66 81.88 181.8 1.5x / 1.4x 171/10666 exact, 974 whitespace-normalized

rs-trafilatura is a different extractor, not a port: it never returns None, separates paragraphs with \n\n, and selects different content (248/10666 equal with None == "", 172 of them both empty; 637 equal after collapsing newline runs; median difflib similarity ~0.67 on the first 400 docs).

Metadata

Release files for trafilatura-rs 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for trafilatura-rs 0.1.0
File Size Uploaded Provenance Actions
trafilatura_rs-0.1.0.tar.gz 2.4 MB With provenance Details for trafilatura_rs-0.1.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for trafilatura-rs 0.1.0
File Actions
trafilatura_rs-0.1.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for trafilatura_rs-0.1.0-cp310-abi3-win_amd64.whl
trafilatura_rs-0.1.0-cp310-abi3-manylinux_2_28_x86_64.whl CPython 3.10 abi3 Linux glibc 2.28+ x86-64 Details for trafilatura_rs-0.1.0-cp310-abi3-manylinux_2_28_x86_64.whl
trafilatura_rs-0.1.0-cp310-abi3-manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.28+ ARM64 Details for trafilatura_rs-0.1.0-cp310-abi3-manylinux_2_28_aarch64.whl
trafilatura_rs-0.1.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for trafilatura_rs-0.1.0-cp310-abi3-macosx_11_0_arm64.whl
trafilatura_rs-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for trafilatura_rs-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 11.7 MB

Release files / trafilatura_rs-0.1.0.tar.gz

Download URL trafilatura_rs-0.1.0.tar.gz
Size 2.4 MB
Tags Source
SHA-256 checksum
How to use checksums
db5ba432764be336c26781725d6bcdd6f79dc3fd6e16be7527733c282153dd36
BLAKE2b-256 checksum
How to use checksums
175c43e34322f13dc848173f89112163f2f1259b8c060c3492f0226bc37f6b2c
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 11, 2026.

Transparency log

Release files / trafilatura_rs-0.1.0-cp310-abi3-win_amd64.whl

Download URL trafilatura_rs-0.1.0-cp310-abi3-win_amd64.whl
Size 2.0 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
5cb668737560a804ea22781b5e05ec2d429a008a99aaae9753febe44de1b8f49
BLAKE2b-256 checksum
How to use checksums
62004f89629c1ec4e2b229ac7405947c63a911e9e3d039c434ecc18a7c86a156
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 11, 2026.

Transparency log

Release files / trafilatura_rs-0.1.0-cp310-abi3-manylinux_2_28_x86_64.whl

Download URL trafilatura_rs-0.1.0-cp310-abi3-manylinux_2_28_x86_64.whl
Size 1.9 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
01d6ff4753476f8f9755617d97ae20126ecd1dd54fe3b5f89e8dbe8a28307db0
BLAKE2b-256 checksum
How to use checksums
4960a9fd70269603b94888008e7a667fdd0b6c680eaed444de82d69f9e1841f2
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 11, 2026.

Transparency log

Release files / trafilatura_rs-0.1.0-cp310-abi3-manylinux_2_28_aarch64.whl

Download URL trafilatura_rs-0.1.0-cp310-abi3-manylinux_2_28_aarch64.whl
Size 1.8 MB
Tags CPython 3.10 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
b6fd36d332703e40e2392eb55186ee7623b714c2082d0c1511d41e344b2a7dbe
BLAKE2b-256 checksum
How to use checksums
2c015b36c70f60c0b62a1bd11fcc8cbc1460968f06d538faa0c2910fe39bae0c
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 11, 2026.

Transparency log

Release files / trafilatura_rs-0.1.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL trafilatura_rs-0.1.0-cp310-abi3-macosx_11_0_arm64.whl
Size 1.7 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
244cf711c70333bed50ecff78a7ba376c14e7e12bf3c1bd88173f1eed608b7c4
BLAKE2b-256 checksum
How to use checksums
35d208aebe6d0e68f176d7b6cff619bf9e1922543a2db6822ab06101cc7977d3
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 11, 2026.

Transparency log

Release files / trafilatura_rs-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL trafilatura_rs-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 1.8 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
a22d324616c19db31f98b4412f210b7c6f4a980e2f9ab21fc67df7a8c6fdfa2e
BLAKE2b-256 checksum
How to use checksums
86268e6909e565c257055cf706bf66cd96384472460eeb1f15939b91688e5831
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 11, 2026.

Transparency log

Security for trafilatura-rs 0.1.0

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 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for trafilatura_rs-0.1.0.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 11, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page