Skip to main content

scah for Python

CSS selectors meet streaming HTML parsing. Extract exactly what you select, without building a DOM.

Python bindings for scah, a Rust HTML extraction library. scah matches CSS selectors in a single forward pass over the document and stores only the matches.

pip install scah

Usage

from scah import Query, Save, parse

html = """
<main>
  <section><a href="/one">One</a><div><a href="/two">Two</a></div></section>
</main>
"""

query = (
    Query.all("main > section", Save.none())
    .then(lambda section: [
        section.all("> a[href]", Save.only_text()),
        section.all("div a", Save.only_text()),
    ])
    .build()
)

store = parse(html, [query])
for section in store.get("main > section"):
    for link in section.get("> a[href]"):
        print(link.text, link.get_attribute("href"))  # One /one

Save controls what is captured for each match: Save.all(), Save.only_inner_html(), Save.only_raw_text(), Save.only_text(), or Save.none() (attributes only). Each element exposes name, id, class_name, attributes, inner_html, raw_text, text, and get(selector) for nested query results.

See the main README for supported selectors and text-extraction semantics.

Benchmarks

Library WHATWG spec Nested (all) Flat (all) Flat (first)
Scah 116 ms 25.2 ms 8.61 ms 47.0 µs
Selectolax 340 ms (2.94×) 162 ms (6.43×) 21.2 ms (2.46×) 9.23 ms (196×)
lxml 769 ms (6.65×) 970 ms (38.4×) 53.0 ms (6.16×) 15.9 ms (337×)
Parsel 1.80 s (15.5×) 767 ms (30.4×) 200 ms (23.2×) 25.8 ms (550×)
Gazpacho 3.81 s (33.0×) — 556 ms (64.6×) 156 ms (3,325×)
BS4 (lxml) 5.45 s (47.1×) 2.15 s (85.3×) 248 ms (28.8×) 246 ms (5,235×)

Mean time per parse and query; lower is better. Multipliers are relative to scah. Synthetic inputs use 10,000 elements. Measured 2026-04-08 to 2026-07-15; raw data and run details in benches/results/python.

License

MIT

Metadata

Release files for scah 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for scah 0.1.0
File
scah-0.1.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
scah-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
scah-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
scah-0.1.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
scah-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details

Total release size: 2.1 MB

Release files / scah-0.1.0-cp310-abi3-win_amd64.whl

Download URL scah-0.1.0-cp310-abi3-win_amd64.whl
Size 410.0 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
f090722a5d947a392b1ba71922964d623979eacd64eda4584f3fee52a09c1264
BLAKE2b-256 checksum
How to use checksums
08114312f3174efae50b469d42bf2becc10dab50ef74e20c56919ca2d1a37f8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.

Transparency log

Release files / scah-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL scah-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 445.2 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
8200c89200d78e225df51a2920cc739e2bfc509bbc084a0674191b5ef47866fa
BLAKE2b-256 checksum
How to use checksums
acc5e1ec0076e144107c932c210831d0868b73276061ba683de4f5ccf673ae63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.

Transparency log

Release files / scah-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL scah-0.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 414.9 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
fbd68d1370a512022b7b18e8532460cad65e82337344dcb743cd84e64eaa72f6
BLAKE2b-256 checksum
How to use checksums
de6c74897ffa42766a3ee771a0852f77831710593f358aa9681acd00e507be4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.

Transparency log

Release files / scah-0.1.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL scah-0.1.0-cp310-abi3-macosx_11_0_arm64.whl
Size 403.5 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
4025abc57ebd016bd0e320f0232de7db997ab06a094f0df94c873b8e435fd483
BLAKE2b-256 checksum
How to use checksums
2fef7fe8b16164d66abaf60e83d7ec70aaa2d5c511ddad5d390c2e0e3749ec35
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.

Transparency log

Release files / scah-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL scah-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 429.5 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
d160ef89c900f25ab2f7056d3edc9b0b27f05d151c6f82a794d34acfda0d3a9c
BLAKE2b-256 checksum
How to use checksums
97a215430fc53d8ed28c3c36dd368e21d780b8f39151b0c8a45640f0a6558bd6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

5 release files

0.0.21

5 release files

0.0.16

5 release files

0.0.15

5 release files

0.0.14

5 release files

0.0.13

5 release files

0.0.12

5 release files

0.0.11

5 release files

0.0.10

5 release files

0.0.9

5 release files

0.0.8

5 release files

0.0.7

5 release files

0.0.6

5 release files

0.0.5

5 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page