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

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.

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 project documentation and CLI help (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.3.tar.gz (20.8 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.3-py3-none-win_amd64.whl (29.2 MB view details)

Uploaded Python 3Windows x86-64

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

Uploaded Python 3manylinux: glibc 2.28+ x86-64

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

Uploaded Python 3manylinux: glibc 2.28+ ARM64

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

Uploaded Python 3macOS 13.0+ x86-64

contextractor-0.4.3-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.3.tar.gz.

File metadata

  • Download URL: contextractor-0.4.3.tar.gz
  • Upload date:
  • Size: 20.8 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.3.tar.gz
Algorithm Hash digest
SHA256 b41995f0a968141871896fb8f4d12151dfca26409d52313d4457fa5e32fd717f
MD5 e25731ccf5cacaca69a12cf1add018af
BLAKE2b-256 67f6f869f85e98d2491855af5fdc1d8d72cd6a3c539d8e1e3fa29fde2fedfbbf

See more details on using hashes here.

Provenance

The following attestation bundles were made for contextractor-0.4.3.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.3-py3-none-win_amd64.whl.

File metadata

  • Download URL: contextractor-0.4.3-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.3-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 edaf3f59db63127ad08a6f245656221f581d3f1892a7c56efba6ecfa545fab00
MD5 9b6c177205ffb79ca1166cf417902ee1
BLAKE2b-256 fa73c7f332ef64505372acc09320f5ea1795a159b4f62fbaf9a4d94d91596f47

See more details on using hashes here.

Provenance

The following attestation bundles were made for contextractor-0.4.3-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.3-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for contextractor-0.4.3-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4546f9c0ecf4f45390c9c341026f215181d2a08483a1db4231543ac1c807f2aa
MD5 6496413066a29f4a33edda036068c26e
BLAKE2b-256 a67d5c27c54259efa222620d35a8d70a828f2f1252f270797244f61317aa540e

See more details on using hashes here.

Provenance

The following attestation bundles were made for contextractor-0.4.3-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.3-py3-none-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for contextractor-0.4.3-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b7b9f227e3fef92fe1551c1d5d3c7b63db55f7f29641d066b69b7032603001c0
MD5 17b81491f79f33834754661a2f336968
BLAKE2b-256 686f28e6727e1e35412b9e60512116f568aac90d12aabe61a0e1eac02d6e7a78

See more details on using hashes here.

Provenance

The following attestation bundles were made for contextractor-0.4.3-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.3-py3-none-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for contextractor-0.4.3-py3-none-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 6632df3b6df9c17cc5ac26f1d3ba951ce9d9385ca35cade204d4a83123a86d34
MD5 b02b0ac27fd2370fd48c76c4f5154931
BLAKE2b-256 869ffc76d15ecba1233dc4f0bce3d4e65c74ae5a21e98931690496eddf130e11

See more details on using hashes here.

Provenance

The following attestation bundles were made for contextractor-0.4.3-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.3-py3-none-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for contextractor-0.4.3-py3-none-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 6a6affce395ac8e6b387fdef68ba5848762368c98ba08f796861538552616fb0
MD5 ad7a5aafe0feaa24946a6cd090e11fba
BLAKE2b-256 06c9da0d49425e99468aba4d04ab1ca2114150b36652944fc2a2d625d0bd1694

See more details on using hashes here.

Provenance

The following attestation bundles were made for contextractor-0.4.3-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