Drive the Contextractor Node crawler/extractor from Python; clean main content in txt/markdown/json/html, plus raw original HTML.
Project description
contextractor
Details & badges:Also available as:
Social: |
Drive the Contextractor Node crawler/extractor from Python; clean main content in txt/markdown/json/html, plus raw original HTML.
⚠️ Alpha / experimental. This Python wrapper for Contextractor is currently an alpha, experimental release — not fully tested or officially supported, though still maintained.
Crawl web pages and extract clean main-content text — txt, markdown, json,
html, or raw original HTML — from Python. Built on rs-trafilatura
(extraction) and Crawlee with Playwright or a pure-HTTP
Cheerio crawler (crawling).
This package is a thin, typed wrapper that drives the bundled Node engine. A
self-contained Node runtime is installed automatically as a dependency
(nodejs-wheel-binaries), so no separate Node.js install is required.
Homepage & docs: www.contextractor.com · Python guide
Contents
Why Contextractor
Contextractor ships the Rust port of Trafilatura as a native (napi-rs) binding — no Python extraction runtime. On the Scrapinghub article set it scores an F1 of 0.966 (precision 0.942, recall 0.991) — ahead of go-trafilatura (0.960) and the original Python Trafilatura (0.958); see the benchmark write-up for the methodology.
It is free and open source (Apache-2.0), runs locally with no API key and no per-page credits, and its Markdown output is typically 80–90% fewer tokens than the raw HTML — cheap to feed to an LLM.
| Contextractor | Firecrawl | Jina Reader | Crawl4AI | |
|---|---|---|---|---|
| Extraction engine | rs-trafilatura (heuristic + ML routing) | LLM / heuristic | ReaderLM neural model | LLM / heuristic |
| Runtime | Rust + Node (no Python engine) | hosted API / self-host | hosted API | Python |
| Surfaces | Apify Actor · npm CLI · npm library · PyPI | API · SDKs · self-hosted · MCP | API | Python library · crwl CLI · Docker REST API · MCP |
| Output formats | txt · markdown · json · html · original | markdown · html · etc. | markdown · html · text · screenshot · etc. | markdown · etc. |
| Crawling | Crawlee + Playwright (adaptive / browser / HTTP) | built-in | none (single URL) | built-in |
Install
pip install contextractor
python -m contextractor install # one-time: download the Chromium browser
Platform wheels are published for macOS (arm64, x86_64), Linux (x86_64, aarch64; glibc ≥ 2.28), and Windows (x64). Requires Python 3.12+.
Quick start
Crawl one or more URLs and write extracted files plus a manifest.json index to
output_dir:
import contextractor
summary = contextractor.extract(
["https://en.wikipedia.org/wiki/Web_scraping"],
save=["markdown-kvs"],
output_dir="./out",
)
print(summary.succeeded, "of", summary.total)
Each save token is <format>-<kvs|dataset> — the format name plus the
destination — so it reads markdown-kvs, not bare markdown (the bare names
like markdown and json are what extract_one(formats=[...]) takes instead).
An async variant, aextract(), takes the same arguments. Partial failures do
not raise — they are reflected in summary.failed; validation and real crawl
failures raise ContextractorError, and a missing browser raises
MissingBrowserError pointing you at python -m contextractor install.
Single-page extraction
extract_one() crawls exactly one URL (no link-following) and returns the
extracted content directly — nothing is written to disk:
import contextractor
markdown = contextractor.extract_one("https://en.wikipedia.org/wiki/Web_scraping") # -> str
contents = contextractor.extract_one( # -> dict[str, str]
"https://en.wikipedia.org/wiki/Web_scraping",
formats=["markdown", "json", "original"],
)
With one requested format the return value is a str; with several it is a
dict[str, str]. aextract_one() is the async variant.
Options
Every crawl option is a typed keyword argument; the ExtractOptions /
ExtractOneOptions TypedDicts are the authoritative list of keywords and
accepted values, surfaced to editors and type checkers (e.g. save, mode,
proxy, cookies, headers, max_crawl_depth, globs). See also the
Python documentation. Each Python
keyword maps one-to-one onto a flag of the npm CLI, documented at
contextractor.com/help/npm.
Only http, https, socks4, and socks5 proxy URLs are accepted; credentials
are never echoed in errors or logs. Set CONTEXTRACTOR_NODE_PATH to use a host
Node binary instead of the bundled runtime.
Links
- Product site and docs: contextractor.com (Python help page)
- Source: github.com/contextractor/contextractor
- Questions and bug reports: open an issue
Contributing
Issues and pull requests are welcome at the issue tracker. The extraction engine, npm CLI, and Apify Actor all live in the same source repository.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file contextractor-0.4.11.tar.gz.
File metadata
- Download URL: contextractor-0.4.11.tar.gz
- Upload date:
- Size: 23.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a344322fd2c3d7df65cb2af8fa1027c14fd1e0f0a4057a954dd73918d83784c
|
|
| MD5 |
fae509611fc9ded369fd06c3809d4190
|
|
| BLAKE2b-256 |
51279d6913690f2f9b35301fb8f5c8d6d5e3aee2a12b3d0eb4e967e3b22905c3
|
Provenance
The following attestation bundles were made for contextractor-0.4.11.tar.gz:
Publisher:
release-pypi.yml on contextractor/contextractor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
contextractor-0.4.11.tar.gz -
Subject digest:
4a344322fd2c3d7df65cb2af8fa1027c14fd1e0f0a4057a954dd73918d83784c - Sigstore transparency entry: 2056103810
- Sigstore integration time:
-
Permalink:
contextractor/contextractor@4002f758bb9222b0546a97b6ec6526b6d7fa0151 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/contextractor
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@4002f758bb9222b0546a97b6ec6526b6d7fa0151 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file contextractor-0.4.11-py3-none-win_amd64.whl.
File metadata
- Download URL: contextractor-0.4.11-py3-none-win_amd64.whl
- Upload date:
- Size: 29.0 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7750606a2ae8106bcc3e17649f83c9036803f76533e7b171ce624a6ccbff4244
|
|
| MD5 |
b6d58f466a2eef21e4731acb50e863f6
|
|
| BLAKE2b-256 |
2f22d1f8d9409b9b3ab75f4d2f561ac8509245e4d55695a674cb6e26b2ac8d74
|
Provenance
The following attestation bundles were made for contextractor-0.4.11-py3-none-win_amd64.whl:
Publisher:
release-pypi.yml on contextractor/contextractor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
contextractor-0.4.11-py3-none-win_amd64.whl -
Subject digest:
7750606a2ae8106bcc3e17649f83c9036803f76533e7b171ce624a6ccbff4244 - Sigstore transparency entry: 2056106711
- Sigstore integration time:
-
Permalink:
contextractor/contextractor@4002f758bb9222b0546a97b6ec6526b6d7fa0151 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/contextractor
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@4002f758bb9222b0546a97b6ec6526b6d7fa0151 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file contextractor-0.4.11-py3-none-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: contextractor-0.4.11-py3-none-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 29.1 MB
- Tags: Python 3, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
44d2b0c280525c36b31c73a3ea23f8d7b589b88af2197d4f16fac80203a1c36b
|
|
| MD5 |
0214e7953eb963b50e850a2708939b95
|
|
| BLAKE2b-256 |
ee42d88f021909d49deae004186079b0746f20ce8317bad7ec1e54ee2f7875c1
|
Provenance
The following attestation bundles were made for contextractor-0.4.11-py3-none-manylinux_2_28_x86_64.whl:
Publisher:
release-pypi.yml on contextractor/contextractor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
contextractor-0.4.11-py3-none-manylinux_2_28_x86_64.whl -
Subject digest:
44d2b0c280525c36b31c73a3ea23f8d7b589b88af2197d4f16fac80203a1c36b - Sigstore transparency entry: 2056105727
- Sigstore integration time:
-
Permalink:
contextractor/contextractor@4002f758bb9222b0546a97b6ec6526b6d7fa0151 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/contextractor
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@4002f758bb9222b0546a97b6ec6526b6d7fa0151 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file contextractor-0.4.11-py3-none-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: contextractor-0.4.11-py3-none-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 29.0 MB
- Tags: Python 3, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38e6f249797fc681f2e731b08818239e2e4a2ec966870d1ec872efb24b4c6518
|
|
| MD5 |
f157d2b83f78d34009b580a2a83926d4
|
|
| BLAKE2b-256 |
616c3bf54d1a212fd1f160ce9bffbc5e35e89e0b5ad2c08c78f543e88959d208
|
Provenance
The following attestation bundles were made for contextractor-0.4.11-py3-none-manylinux_2_28_aarch64.whl:
Publisher:
release-pypi.yml on contextractor/contextractor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
contextractor-0.4.11-py3-none-manylinux_2_28_aarch64.whl -
Subject digest:
38e6f249797fc681f2e731b08818239e2e4a2ec966870d1ec872efb24b4c6518 - Sigstore transparency entry: 2056107183
- Sigstore integration time:
-
Permalink:
contextractor/contextractor@4002f758bb9222b0546a97b6ec6526b6d7fa0151 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/contextractor
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@4002f758bb9222b0546a97b6ec6526b6d7fa0151 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file contextractor-0.4.11-py3-none-macosx_13_0_x86_64.whl.
File metadata
- Download URL: contextractor-0.4.11-py3-none-macosx_13_0_x86_64.whl
- Upload date:
- Size: 29.0 MB
- Tags: Python 3, macOS 13.0+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ba7c96194668b8e4242eaf765f77300f9df3dbc3fc7e15daf0b8f356aef0eb2
|
|
| MD5 |
a313288f7f8816ec0f88cd5f75a7c7a6
|
|
| BLAKE2b-256 |
e57a0601bb8408d07075f9ec011422cf1b6e92ead9ed62c8d17f60be35ebc4d5
|
Provenance
The following attestation bundles were made for contextractor-0.4.11-py3-none-macosx_13_0_x86_64.whl:
Publisher:
release-pypi.yml on contextractor/contextractor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
contextractor-0.4.11-py3-none-macosx_13_0_x86_64.whl -
Subject digest:
3ba7c96194668b8e4242eaf765f77300f9df3dbc3fc7e15daf0b8f356aef0eb2 - Sigstore transparency entry: 2056104156
- Sigstore integration time:
-
Permalink:
contextractor/contextractor@4002f758bb9222b0546a97b6ec6526b6d7fa0151 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/contextractor
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@4002f758bb9222b0546a97b6ec6526b6d7fa0151 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file contextractor-0.4.11-py3-none-macosx_13_0_arm64.whl.
File metadata
- Download URL: contextractor-0.4.11-py3-none-macosx_13_0_arm64.whl
- Upload date:
- Size: 28.9 MB
- Tags: Python 3, macOS 13.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
30a1efcac4860a3e2065e3fae4f20e90468db8513c07295b868cb10f4c8c50f3
|
|
| MD5 |
c57b001ca432139efa41ae43aa3e6b40
|
|
| BLAKE2b-256 |
e3726af794a3d5640b3a558496df88c5c217e4a0b630296ba5017cc975843e6c
|
Provenance
The following attestation bundles were made for contextractor-0.4.11-py3-none-macosx_13_0_arm64.whl:
Publisher:
release-pypi.yml on contextractor/contextractor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
contextractor-0.4.11-py3-none-macosx_13_0_arm64.whl -
Subject digest:
30a1efcac4860a3e2065e3fae4f20e90468db8513c07295b868cb10f4c8c50f3 - Sigstore transparency entry: 2056105015
- Sigstore integration time:
-
Permalink:
contextractor/contextractor@4002f758bb9222b0546a97b6ec6526b6d7fa0151 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/contextractor
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@4002f758bb9222b0546a97b6ec6526b6d7fa0151 -
Trigger Event:
workflow_dispatch
-
Statement type: