Skip to main content

trafilatura-rs

PyPI Python versions CI License

A Rust port of trafilatura's main-text extraction that returns the same output, byte for byte, as trafilatura.extract(), using about a tenth of the CPU.

CPU per page: trafilatura 17.93 ms, rs-trafilatura 12.24 ms, trafilatura-rs 1.92 ms

Installation

pip install "trafilatura-rs[trafilatura]"

The [trafilatura] extra installs the exact versions trafilatura-rs is verified against (trafilatura 1.11.0, lxml 6.1.3), so you can fall back to and compare with the original. Wheels are built for Linux, macOS and Windows, Python 3.10+, with libxml2 statically linked.

Quickstart

Your existing code, unchanged:

TRAFILATURA_RS=1 python my_script.py

Every trafilatura.extract call trafilatura-rs supports now runs in Rust; every other call runs Python trafilatura as before. That includes calls made inside other libraries; datatrove's Trafilatura step, for example, is covered (or use datatrove-rs).

Prefer it in code? Any of these works too:

import trafilatura_rs
trafilatura_rs.install()          # patch trafilatura.extract, including copies imported earlier

from trafilatura_rs import extract  # or swap the import: same signature, falls back to Python when needed

You can also run a script unmodified with python -m trafilatura_rs my_script.py.

To run in Rust, a call has to pass include_comments=False; trafilatura's default is True:

trafilatura.extract(html, include_comments=False, favor_precision=True)  # Rust
trafilatura.extract(html, favor_precision=True)                          # Python (comments not ported yet)

trafilatura_rs.supports(**kwargs) tells you which path a call takes. If your installed trafilatura or lxml isn't the version trafilatura-rs reproduces, every call stays on Python and install() warns, so results never change.

What's supported

Plain-text extract() with include_comments=False, string input, in these configurations (trafilatura_rs.VERIFIED). Other arguments, bytes input and other output formats run Python trafilatura.

Configuration Arguments Identical to trafilatura
Default 10,666 / 10,666
Precision (datatrove / FineWeb) favor_precision=True, deduplicate=True 10,666 / 10,666
Recall favor_recall=True 10,666 / 10,666
Fast no_fallback=True 10,666 / 10,666
No tables include_tables=False 10,666 / 10,666

deduplicate=True is verified with the precision configuration (datatrove's call). Like trafilatura, it keeps a process-global cache, so output depends on document order exactly as in Python; trafilatura_rs.reset_caches() clears it.

Exactness

Each configuration is checked page by page against trafilatura 1.11.0 on 10,666 Common Crawl pages, comparing final output and per-stage tree hashes. The jusText and readability fallbacks are checked separately. Exactness holds because the parser is the same: trafilatura-rs vendors and statically links libxml2 2.14.6, the version lxml 6.1.3 bundles, with the same parsing options (see PATCHES.md).

A port of trafilatura 2.2.0's extraction is verified by the same harness but not yet exposed in Python (differences: docs/trafilatura-2x-diff.md).

How is this different from rs-trafilatura?

rs-trafilatura is an independent extractor inspired by trafilatura, not a port. On the same 10,666 pages its output equals trafilatura's on 171. It never returns None, separates paragraphs differently and often selects different content. Use trafilatura-rs when you need trafilatura's results, for example to reproduce a dataset.

Benchmark

Single thread, CPU time per page, 10,666 Common Crawl pages, favor_precision=True (tools/bench.sh):

mean p50 p99 Speedup
trafilatura 1.11 17.93 ms 11.19 ms 110.83 ms 1x
rs-trafilatura 0.1.1 12.24 ms 7.66 ms 81.88 ms 1.5x
trafilatura-rs 1.92 ms 1.25 ms 11.85 ms 9.3x

Measured by instruction count, the speedup is 11.3x.

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

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.1
File Size Uploaded Provenance Actions
trafilatura_rs-0.1.1.tar.gz 2.4 MB With provenance Details for trafilatura_rs-0.1.1.tar.gz

Built distributions (wheels)

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

Total release size: 11.7 MB

Release files / trafilatura_rs-0.1.1.tar.gz

Download URL trafilatura_rs-0.1.1.tar.gz
Size 2.4 MB
Tags Source
SHA-256 checksum
How to use checksums
8134179eb055cef215d6f8298781841c8011d9609f8eb7cfe1cf07c70d26f55c
BLAKE2b-256 checksum
How to use checksums
2d0d9139d1a8c035b477d419420ebc64cfbbafa53051869c1353d34e917bf0c2
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.1-cp310-abi3-win_amd64.whl

Download URL trafilatura_rs-0.1.1-cp310-abi3-win_amd64.whl
Size 2.0 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
affb3db137a48522f8b38749913e6745898b010f7dee4ecfb4f2bb3e75301d2a
BLAKE2b-256 checksum
How to use checksums
3f154f6462e67340d1920809a2f4b912610579c34a7d378780cf47b8fba6b8da
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.1-cp310-abi3-manylinux_2_28_x86_64.whl

Download URL trafilatura_rs-0.1.1-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
8c57f7ff4da6eb85463aaa65a5599f58ce5913fd6d766388748b0a154443396b
BLAKE2b-256 checksum
How to use checksums
1d6b77a4e0043dad7e82786cc69e2382b930f85d608f6e1ff10d418169449005
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.1-cp310-abi3-manylinux_2_28_aarch64.whl

Download URL trafilatura_rs-0.1.1-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
5174d1fb117ec2f6e79e5b87d8fa139c1cadce8b591e2fd2954a7d003bf5a5a6
BLAKE2b-256 checksum
How to use checksums
1ab808252ffe4a1adb8167a84640f510bb9b0c11bc11a85e51281079d157a9b7
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.1-cp310-abi3-macosx_11_0_arm64.whl

Download URL trafilatura_rs-0.1.1-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
b38978490a37e8aa9877db473063152c638b73aab93d8917a8098c0ee80ab3a9
BLAKE2b-256 checksum
How to use checksums
b5902097bf703f95c176d50b13c1b83375dd78eb9a86c97e5732426b96041ee1
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.1-cp310-abi3-macosx_10_12_x86_64.whl

Download URL trafilatura_rs-0.1.1-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
c95dbc5f557953a5f99d2d57918733179b704dc866906d47bd6f7e1b1791172a
BLAKE2b-256 checksum
How to use checksums
c5d31930e49beb5bc02340ee4b2b50399ef54ae039ce575178131aa0c68dcd8f
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.1

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