Skip to main content

contextractor

Contextractor PyPI version PyPI downloads license

Also available as:

Online playground playground, help | Apify Actor actor, help | NPM package CLI & lib package, CLI help, lib help | Source code on GitHub

Social:

X (Twitter)

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 CLI. A self-contained Node runtime is installed automatically as a dependency (nodejs-wheel-binaries), so no separate Node.js install is required — but no Python code touches the extraction engine itself.

Install

pip install contextractor
python -m contextractor install   # one-time: download the 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

extract_one() fetches exactly one URL (no link-following) and returns the extracted content directly; the cheerio crawler works before any browser download:

>>> import contextractor
>>> md = contextractor.extract_one(
...     "https://www.iana.org/help/example-domains",
...     crawler_type="cheerio",
... )
>>> md.splitlines()[0]
'# Example Domains'

With one requested format the return value is a str; with several it is a dict[str, str]:

>>> contents = contextractor.extract_one(
...     "https://www.iana.org/help/example-domains",
...     formats=["markdown", "json", "original"],
...     crawler_type="cheerio",
... )
>>> sorted(contents)
['json', 'markdown', 'original']

aextract_one() is the async variant.

Crawling multiple pages

extract() crawls one or more URLs (with link-following) and writes 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.

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. Each snake_case keyword maps one-to-one onto a flag of the npm CLI:

  • max_crawl_depth=3 → --max-crawl-depth 3
  • headless=False → --no-headless
  • save=["markdown-kvs", "json-dataset"] → --save markdown-kvs --save json-dataset

See the Python documentation for the full keyword list. 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.

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

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

Apache-2.0

Metadata

Release files for contextractor 0.4.14

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

Source distribution (sdist)

Source distribution for contextractor 0.4.14
File Size Uploaded Provenance Actions
contextractor-0.4.14.tar.gz 23.2 kB With provenance Details for contextractor-0.4.14.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for contextractor 0.4.14
File Actions
contextractor-0.4.14-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for contextractor-0.4.14-py3-none-win_amd64.whl
contextractor-0.4.14-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details for contextractor-0.4.14-py3-none-manylinux_2_28_x86_64.whl
contextractor-0.4.14-py3-none-manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.28+ ARM64 Details for contextractor-0.4.14-py3-none-manylinux_2_28_aarch64.whl
contextractor-0.4.14-py3-none-macosx_13_0_x86_64.whl Python 3 none macOS 13.0+ x86-64 Details for contextractor-0.4.14-py3-none-macosx_13_0_x86_64.whl
contextractor-0.4.14-py3-none-macosx_13_0_arm64.whl Python 3 none macOS 13.0+ ARM64 Details for contextractor-0.4.14-py3-none-macosx_13_0_arm64.whl

Total release size: 145.0 MB

Release files / contextractor-0.4.14.tar.gz

Download URL contextractor-0.4.14.tar.gz
Size 23.2 kB
Tags Source
SHA-256 checksum
How to use checksums
efd1a8005569e98997d163772449cb79911b36611467db0d23713498662bceb2
BLAKE2b-256 checksum
How to use checksums
7a79b491d2268736c3de93e0917af87b99812f09a0a6e9b4408ee12b376bdb38
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jul 5, 2026.

Transparency log

Release files / contextractor-0.4.14-py3-none-win_amd64.whl

Download URL contextractor-0.4.14-py3-none-win_amd64.whl
Size 29.0 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
ffdbf6902e570d029ed56abe2876790e8eb0ceb4be5f96978631f2461e6c7145
BLAKE2b-256 checksum
How to use checksums
d9fcc86e1d48e37b2a27d780f2ed902cc3c0a3ec894b9eb5534ac2e2dec72253
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jul 5, 2026.

Transparency log

Release files / contextractor-0.4.14-py3-none-manylinux_2_28_x86_64.whl

Download URL contextractor-0.4.14-py3-none-manylinux_2_28_x86_64.whl
Size 29.1 MB
Tags Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
c6555692fb7baefeacd012b6a181a3f5289af7e6b608972322189c67aada0953
BLAKE2b-256 checksum
How to use checksums
736ae8768e4128f38182c9c95e560f630b03527c86ecd97e2e5d3c5308041ac6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jul 5, 2026.

Transparency log

Release files / contextractor-0.4.14-py3-none-manylinux_2_28_aarch64.whl

Download URL contextractor-0.4.14-py3-none-manylinux_2_28_aarch64.whl
Size 29.0 MB
Tags Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
3d943f3ebcaddcad370e1a570659989ea3a9c29a2d7d8c71cd65190ba9da236b
BLAKE2b-256 checksum
How to use checksums
a909ce3900eec6a9a419d18183ae8658a698804ad8d0cce6656d7a93732e0434
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jul 5, 2026.

Transparency log

Release files / contextractor-0.4.14-py3-none-macosx_13_0_x86_64.whl

Download URL contextractor-0.4.14-py3-none-macosx_13_0_x86_64.whl
Size 29.0 MB
Tags Python 3 macOS 13.0+ x86-64
SHA-256 checksum
How to use checksums
6dc7a2886d88c2fb009a109be22e3c2f8a9fdbf1097593952c8f2a2b31736abc
BLAKE2b-256 checksum
How to use checksums
5d046c41583c8be43a65161485a268b872742d33d9bfda9646f0af2b74eb70c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jul 5, 2026.

Transparency log

Release files / contextractor-0.4.14-py3-none-macosx_13_0_arm64.whl

Download URL contextractor-0.4.14-py3-none-macosx_13_0_arm64.whl
Size 28.9 MB
Tags Python 3 macOS 13.0+ ARM64
SHA-256 checksum
How to use checksums
a198d24d21f4c15a374865375fad17a42b80de1f37c780a7a79cdb32f25045dd
BLAKE2b-256 checksum
How to use checksums
73e29d90df6b262ab83b070e5a49554c1d8741f4eec85372ee08fd643923906d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jul 5, 2026.

Transparency log

Security for contextractor 0.4.14

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 contextractor-0.4.14.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 Jul 5, 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