Skip to main content

Drive the Contextractor Node crawler/extractor from Python — clean main-content text in txt, markdown, json, or html.

Project description

contextractor

Contextractor

PyPI version PyPI downloads license

Crawl web pages and extract clean main-content text — txt, markdown, json, or html — from Python. Built on rs-trafilatura (extraction) and Crawlee + Playwright (crawling).

This package is a thin, typed wrapper that drives the bundled Node engine — a self-contained Node runtime ships with the wheel, so no Node.js install is required.

Homepage & docs: www.contextractor.com · Python guide

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://example.com"],
    save=["markdown-kvs"],
    output_dir="./out",
)
print(summary.succeeded, "of", summary.total)

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://example.com")          # -> str

contents = contextractor.extract_one(                                # -> dict[str, str]
    "https://example.com",
    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, surfaced to editors and type checkers via the ExtractOptions / ExtractOneOptions TypedDicts (e.g. save, mode, proxy, cookies, headers, max_crawl_depth, globs). For the full, authoritative option reference see the Python documentation (and contextractor extract --help); the Python keywords map one-to-one onto the CLI flags.

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.

License

Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

contextractor-0.4.8.tar.gz (21.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

contextractor-0.4.8-py3-none-win_amd64.whl (29.2 MB view details)

Uploaded Python 3Windows x86-64

contextractor-0.4.8-py3-none-manylinux_2_28_x86_64.whl (29.3 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

contextractor-0.4.8-py3-none-manylinux_2_28_aarch64.whl (29.2 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

contextractor-0.4.8-py3-none-macosx_13_0_x86_64.whl (29.2 MB view details)

Uploaded Python 3macOS 13.0+ x86-64

contextractor-0.4.8-py3-none-macosx_13_0_arm64.whl (29.1 MB view details)

Uploaded Python 3macOS 13.0+ ARM64

File details

Details for the file contextractor-0.4.8.tar.gz.

File metadata

  • Download URL: contextractor-0.4.8.tar.gz
  • Upload date:
  • Size: 21.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for contextractor-0.4.8.tar.gz
Algorithm Hash digest
SHA256 91c7a60bd6dc299f210f2fa96ecfb67fb515c50c6286b9721c4c82fe0916c52c
MD5 5815e79f6c955e72a0635896e7b9ffdc
BLAKE2b-256 f1b90c03228120b4af01210289642d3f642ee493f273362242a23fbf51b2b3f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for contextractor-0.4.8.tar.gz:

Publisher: release-pypi.yml on contextractor/contextractor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file contextractor-0.4.8-py3-none-win_amd64.whl.

File metadata

  • Download URL: contextractor-0.4.8-py3-none-win_amd64.whl
  • Upload date:
  • Size: 29.2 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for contextractor-0.4.8-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 2885e58bd0817508d1d2032df17f627be629334eaab469bae90b73cfe26280f3
MD5 a7e3ea1768552f06d09b7cb6ae870503
BLAKE2b-256 5d3d5f71ef7109285100338ca9d444f7287b00a1063a8e19fd8e788ea1a58067

See more details on using hashes here.

Provenance

The following attestation bundles were made for contextractor-0.4.8-py3-none-win_amd64.whl:

Publisher: release-pypi.yml on contextractor/contextractor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file contextractor-0.4.8-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for contextractor-0.4.8-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 92e5396f2e16da3a73d829c563679e3ae5a0d85c6482e5b1fa39872e565b34ee
MD5 ec68d35d1fd9f51fed8f39177bfba517
BLAKE2b-256 8f76d9f299072d419a5515e9176252929b352b2ef7988fde374c4ac2f911b6df

See more details on using hashes here.

Provenance

The following attestation bundles were made for contextractor-0.4.8-py3-none-manylinux_2_28_x86_64.whl:

Publisher: release-pypi.yml on contextractor/contextractor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file contextractor-0.4.8-py3-none-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for contextractor-0.4.8-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 12b866a625e53de3ac5eabcb8b051ca4774c4b631cf85c0baf1dc3f5ef4804cd
MD5 70b15c478f876cac6b200aa7640e8c09
BLAKE2b-256 88722497e79c51a6ea23a2e1931a379aa088ecf16057aee2630eba6d96d489b2

See more details on using hashes here.

Provenance

The following attestation bundles were made for contextractor-0.4.8-py3-none-manylinux_2_28_aarch64.whl:

Publisher: release-pypi.yml on contextractor/contextractor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file contextractor-0.4.8-py3-none-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for contextractor-0.4.8-py3-none-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 3406253b23d05fe6ebf7b14aae11077558999f79ccc2fa8f48c2ee9d535a244b
MD5 8127982c2035e35033f0a52576885e1d
BLAKE2b-256 610db0d34ec6be9bc651f14603634c5aaa6f258212be6599293c94c6c69ad289

See more details on using hashes here.

Provenance

The following attestation bundles were made for contextractor-0.4.8-py3-none-macosx_13_0_x86_64.whl:

Publisher: release-pypi.yml on contextractor/contextractor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file contextractor-0.4.8-py3-none-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for contextractor-0.4.8-py3-none-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 506487db3e24952f3ac529165b70711c8cfb3ca8bbc92886615d786d03ca07ce
MD5 b5761efe4a58ded586ce7b185f4b4081
BLAKE2b-256 ff2760832e1b40ee6541d1df03aaa2a6904d93a17ef08bead0a75c1c6ac09bd5

See more details on using hashes here.

Provenance

The following attestation bundles were made for contextractor-0.4.8-py3-none-macosx_13_0_arm64.whl:

Publisher: release-pypi.yml on contextractor/contextractor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page