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.

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.6.tar.gz (20.9 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.6-py3-none-win_amd64.whl (29.2 MB view details)

Uploaded Python 3Windows x86-64

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

Uploaded Python 3manylinux: glibc 2.28+ x86-64

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

Uploaded Python 3manylinux: glibc 2.28+ ARM64

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

Uploaded Python 3macOS 13.0+ x86-64

contextractor-0.4.6-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.6.tar.gz.

File metadata

  • Download URL: contextractor-0.4.6.tar.gz
  • Upload date:
  • Size: 20.9 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.6.tar.gz
Algorithm Hash digest
SHA256 56c5eaf78d7367ba030932b5dd595a254f10aff6400493c4e9889ba9e16a9b65
MD5 bfe145aa8ad2773a84b97f8bea0932da
BLAKE2b-256 6992cccab3e45ec4db5b7d7eb3a6fbd6c25dfb1a252075a9e7cfd81c3c1bef2b

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: contextractor-0.4.6-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.6-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 e5b0eaea065d86131aa7109791b3379d76dc6d658b20fd54c658b5c27a5a4566
MD5 eacf1fbf811f641bc53d46c99fa250b8
BLAKE2b-256 8737a1b0d20225f5e874863918f6bf7adba3127165723b2e010c720e5f4225a2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for contextractor-0.4.6-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8a34c1d8f3db3b3c8e4e531ffac72a6d8c74330d2b102b4f9f364ac0794411c3
MD5 7745a2d18177d2549a6b34e0920be0b0
BLAKE2b-256 99a566751f76cc87ad617ec4e4a1572d9dd63f3e0521ca129bcd91dbf456a335

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for contextractor-0.4.6-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f187f5be4afffea5788696096a4c17121adf13c2ef0818172952cc42eae7a960
MD5 c447c55f2c433bf2c8c9f0cba2939118
BLAKE2b-256 fa19b9d3eaeb6d186c61348fce7254609eaac47cd511969482a1e76f409e8c06

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for contextractor-0.4.6-py3-none-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 92e0fb8c61342ca8e0852ec426138efccc0365e33d6b9d454cc0106a7e2eb59b
MD5 8f4c20891d133be5fc56c9df1cad9250
BLAKE2b-256 8e3c30b8a2d85fadfa7c074f19cd66bfaf9921177e5faf39665a8b86f7ec5c62

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for contextractor-0.4.6-py3-none-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 8616c7834a8c3dbb3b946a73d4dd5972f1814f7dac12cccceb0e9b96c08d4358
MD5 c03f7a65c9d14f5d1e49b7d512c35280
BLAKE2b-256 f7176a48eef76f05f063114be42f885ab7e89dfe30aef1f5a7ca2cff63908243

See more details on using hashes here.

Provenance

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