Skip to main content

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

Project description

contextractor

Contextractor

PyPI version PyPI downloads license

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 + 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.

Links

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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3manylinux: glibc 2.28+ x86-64

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

Uploaded Python 3manylinux: glibc 2.28+ ARM64

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

Uploaded Python 3macOS 13.0+ x86-64

contextractor-0.4.9-py3-none-macosx_13_0_arm64.whl (29.2 MB view details)

Uploaded Python 3macOS 13.0+ ARM64

File details

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

File metadata

  • Download URL: contextractor-0.4.9.tar.gz
  • Upload date:
  • Size: 21.1 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.9.tar.gz
Algorithm Hash digest
SHA256 9a198df0666a784e0f9d367853e5bcc3fd33255165584fd80626502b429ea67b
MD5 9f5e5b35b7e862dfaa2d983bc8f1dfc4
BLAKE2b-256 0fdb00284e55bcec31d51cbb924684496607005805d346237e36333bc557e70b

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: contextractor-0.4.9-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.9-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 0977317d0adf54c290e0e349784980c3165a832e9e6e003d4c0f367ae6362d83
MD5 70483d14ad0813486e778957e5799c61
BLAKE2b-256 a7d859331fddc684191ff11e647fce9459e282765af41a2e38f9479c6f5f51d5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for contextractor-0.4.9-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 046b65dc36994a5cb82c226a21bb050a00e58db5b408e2331355ac2b297f7859
MD5 baeee587459b752a532faf1fd7ce88e5
BLAKE2b-256 fec3c8db46ee26e5974c4fd51f9727ddfedb1c206acd9eec01470cbccc395ace

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for contextractor-0.4.9-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 599d4d5ac22ad979fd78d9d84d106f29d0649a9c7fc26e5fe4f0111fefa1b14f
MD5 b11f27dea189c55e3d2f658d23e4b6d2
BLAKE2b-256 f46de4e8bfe9155088cc6570db11c00a6ec6542f5d9edff42c789d9d229b359d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for contextractor-0.4.9-py3-none-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 1af29d317884696c88b4bd2fd996378eb9eadb6e7613b4718cffd7f5c90cafe4
MD5 76d4769a66aaa1179e1289ed4b10e6e9
BLAKE2b-256 d8ddd38336a2b02593d8ed565a0540d34f438e9ee30bc948ff456b3b4f5de677

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for contextractor-0.4.9-py3-none-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 9dc76cf36f5d3cd5529877879b2cdc2f880b86095fce47c544cee727c3ed5c1a
MD5 559197258a606473849d13b4f6191c2b
BLAKE2b-256 6aaff872001b4216592f09ed276aa6f40a63905b1dea0d74cc6f70b61e2d25fa

See more details on using hashes here.

Provenance

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