trafipy
Python bindings for the rs-trafilatura
crate — fast heuristic main-content extraction from HTML, in-process, no subprocess.
Unofficial bindings, not affiliated with the
rs-trafilaturaproject.
Install
pip install trafipy
Linux x86-64 wheels are published (manylinux_2_34, abi3 for Python 3.12+), so
glibc 2.34 or newer is required. On anything else pip falls back to the sdist,
which needs a Rust toolchain to compile.
Use
import trafipy
result = trafipy.extract(html, url="https://example.com/page", favor_recall=True)
result.markdown # GitHub Flavored Markdown, "" when nothing was extracted
result.text # plain text of the same region
result.quality # the crate's own predicted F1, in [0, 1]
result.confidence # page-type classification confidence, or None
result.warnings # list[str]
url is the document's own address, used by the crate as context for
canonical-URL and hostname handling. It does not absolutize links in the
returned markdown or text — those come back as the document wrote them. It is
never fetched: there is no HTTP client anywhere in the dependency tree, and this
library makes no network requests.
Options
extract(html, *, url=None, include_tables=True, include_links=True, include_images=True, include_comments=False, favor_recall=True, min_extracted_size=100, deduplicate=False)
Every option is passed straight through to the crate and every value comes back as the crate produced it. The binding makes no extraction decisions of its own.
Two decisions worth knowing
One call returns both textual forms. The crate's ExtractResult carries
content_text and content_markdown together, so output_markdown is set
unconditionally and you pay for one parse. The Python trafilatura API returns
one format per call, so getting both there costs two parses.
Metadata is not exposed. The crate extracts titles, dates and authors, but this binding returns content only. If you already derive your own metadata, surfacing a second set invites mixing them, and two provenance stories for one field is worse than one.
Versioning
rs-trafilatura is pinned exactly (=0.2.2), and the pin is not a formality.
The crate is pre-1.0, so a minor release can change extraction output — meaning
the same page yields different content across an unpinned upgrade. Bump it
deliberately and re-check against your own fixtures when you do.
Build from source
maturin develop # build and install into the current venv
maturin build --release --out dist --compatibility manylinux_2_28
Requires Rust 1.85+ (the dependency tree uses edition 2024).
License
Dual-licensed under MIT or Apache-2.0, at your option — matching the upstream crate.
The wheel statically links rs-trafilatura and its dependency tree; their
license notices are collected in LICENSE-THIRD-PARTY.md.
Metadata
Release files for trafipy 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| trafipy-0.1.0.tar.gz | 22.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| trafipy-0.1.0-cp312-abi3-manylinux_2_34_x86_64.whl | CPython 3.12 | abi3 | Linux glibc 2.34+ x86-64 | Details |
Total release size: 2.2 MB
Release files / trafipy-0.1.0.tar.gz
| Download URL | trafipy-0.1.0.tar.gz |
|---|---|
| Size | 22.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1577fadb9ba8bfbd660270152f0ac9a95981a5669a5928a66d1773068e32275b
|
|
BLAKE2b-256 checksum How to use checksums |
a2efa860e3b502a65c6c97f441760eea462572907431acefc3a1f2086d86a269
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / trafipy-0.1.0-cp312-abi3-manylinux_2_34_x86_64.whl
| Download URL | trafipy-0.1.0-cp312-abi3-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.12 Linux glibc 2.34+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
77fa6a31f34d9551ae184f26f12891ef0f8ac64d400bc949b7de6596e2ec631c
|
|
BLAKE2b-256 checksum How to use checksums |
ddca82b106b197a721bd0b784aa0497684c4227ab13d804075705912fa35dda3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|