Skip to main content

A Declarative HTML Scraper for Python

This package provides a simple way to declare what data should be extracted from an HTML document in a configuration file.

This enables sharing of scraping logic across projects and teams without the risk of executing untrusted code. It also allows for easier maintenance and updates to scraping logic without needing to modify the underlying codebase.

CLI

The package includes a Click-based CLI with two commands:

spextract parse spec.yaml <path to html file or directory>
spextract validate spec.yaml expected-results.yaml

parse emits YAML in the same expected-results format used by validate, so you can capture known-good output and re-run validation later.

How to use

Build a configuration file

You can write a configuration file with the provided ParserSpec class.

import spextract

spec = spextract.ParserSpec(
    name="example_parser",
    description="An example parser for demonstration purposes.",
    fields=[
        spextract.FieldSpec(
            name="title",
            selector="h1.title::text",
            type=spextract.FieldType.TEXT,
        ),
        spextract.FieldSpec(
            name="links",
            selector="a.link::attr(href)",
            type=spextract.FieldType.LINK,
            multiple=True,
        ),
        spextract.FieldSpec(
            name="author",
            selector="div.author",
            type=spextract.FieldType.OBJECT,
            fields=[
                spextract.FieldSpec(
                    name="name",
                    selector="span.name::text",
                    type=spextract.FieldType.TEXT,
                ),
                spextract.FieldSpec(
                    name="profile_url",
                    selector="a.profile::attr(href)",
                    type=spextract.FieldType.LINK,
                ),
            ]
        ),
    ]
)

Metadata

Release files for spextract 0.6.7

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

Source distribution (sdist)

Source distribution for spextract 0.6.7
File Size Uploaded Provenance Actions
spextract-0.6.7.tar.gz 13.9 kB With provenance Details for spextract-0.6.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for spextract 0.6.7
File Interpreter ABI Platform Actions
spextract-0.6.7-py3-none-any.whl Python 3 none any Details for spextract-0.6.7-py3-none-any.whl

Total release size: 32.6 kB

Release files / spextract-0.6.7.tar.gz

Download URL spextract-0.6.7.tar.gz
Size 13.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7d3015e340b84d5281414fd5527e7131d9f2815c9e0fb39c370c99be3af02507
BLAKE2b-256 checksum
How to use checksums
972055229d3bff5f9c83ce69688cef04541cd51c56582e66c550bda0dfd99eca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 2, 2026.

Transparency log

Release files / spextract-0.6.7-py3-none-any.whl

Download URL spextract-0.6.7-py3-none-any.whl
Size 18.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8fc0cc4ffec1d05938bdc1e765771abd682bce0280400bb9cfe87c39e1b8d533
BLAKE2b-256 checksum
How to use checksums
e899ca873013125da9cf4011578054c1c02034064a89245370b18b3d8ceb8734
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 2, 2026.

Transparency log

Security for spextract 0.6.7

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for spextract-0.6.7.tar.gz

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 Jun 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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