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.4.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.4-py3-none-win_amd64.whl (29.2 MB view details)

Uploaded Python 3Windows x86-64

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

Uploaded Python 3manylinux: glibc 2.28+ x86-64

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

Uploaded Python 3manylinux: glibc 2.28+ ARM64

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

Uploaded Python 3macOS 13.0+ x86-64

contextractor-0.4.4-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.4.tar.gz.

File metadata

  • Download URL: contextractor-0.4.4.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.4.tar.gz
Algorithm Hash digest
SHA256 3ba503a13a9386e9a6c122566665e2b743c6758cd832fe1a7df91f8ceae72fef
MD5 80cfb4816e537940f7baa6fab49c35a6
BLAKE2b-256 521d13cd49faeae0c01ddd003cb5f9056a8f1729e87ef6f06ee04902e1674853

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: contextractor-0.4.4-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.4-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 8956141cff4e0580fec9ae3711da78ff36db9d85b19022ac77e251762425fd2b
MD5 ced67d5a8a4af9fd3ddf37fd656e2849
BLAKE2b-256 e7922b20279880fdc6d15069026d1b59d257f739c447a913d55fb5bdf7139359

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for contextractor-0.4.4-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 821128c0435b7ca5153374bebfd094b08948e0b5856f79f8ec42896f6b7bdeec
MD5 549fd7fb95251ad79f7b678d3296cf7a
BLAKE2b-256 240d16f0942f61cb0486f0afd6c79d0342673c0edf27bc7d948e5d6449389f0a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for contextractor-0.4.4-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 a1d2ad3d1713e4a0b5ebbe792b9511b3b3635f92ffedf6b2a4933b946bcc1e1e
MD5 5fd7044bca2efe40f8bb6344dbc87be9
BLAKE2b-256 eab2edeb4fb9e5201956c5506bd8aecaf3ef83d593c46b5182e69927847acefe

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for contextractor-0.4.4-py3-none-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 3a5385564f00413fdd0fb8e7c650b7b2c1c2d4b3aab1554b559bc7a70d8eeba1
MD5 5bfee4e5f2954fa21cfe71955333a26c
BLAKE2b-256 3f15ab63548ebe02db623e3a738cd0ea841e35e6cb33cb687cfda1c1e3b64599

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for contextractor-0.4.4-py3-none-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 c7faf9d68ed25d76960b59041e0c7da9906ec0b2c0f1289f25f0dcd52524c374
MD5 4c37d3da5e8eb86d05ec2127901706d4
BLAKE2b-256 07f34a7cbef0c7da3d5311c6b2099247f7a8ed2a74542d9a3ad275539546f631

See more details on using hashes here.

Provenance

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