A declarative html scraper for python. Define your scraper spec in a yaml or json to extract data from html documents.
Project description
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,
),
]
),
]
)
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file spextract-0.6.4.tar.gz.
File metadata
- Download URL: spextract-0.6.4.tar.gz
- Upload date:
- Size: 13.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4dee9e1cca492bba8994bdefdfce04b4d9ac5445bec558a61401c1135f28cc9c
|
|
| MD5 |
d7139428cf51a38835e401d2f71809ba
|
|
| BLAKE2b-256 |
9d0df46821efd5b5ecaff2217b556b12f3c7935ca7e5ec479cf4653ae8d61615
|
Provenance
The following attestation bundles were made for spextract-0.6.4.tar.gz:
Publisher:
ci.yml on vincentropy/declarative_scraper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spextract-0.6.4.tar.gz -
Subject digest:
4dee9e1cca492bba8994bdefdfce04b4d9ac5445bec558a61401c1135f28cc9c - Sigstore transparency entry: 1702648127
- Sigstore integration time:
-
Permalink:
vincentropy/declarative_scraper@9d6accb65c58e3c22c7ea3896a2b7232dd07c507 -
Branch / Tag:
refs/tags/v0.6.4 - Owner: https://github.com/vincentropy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@9d6accb65c58e3c22c7ea3896a2b7232dd07c507 -
Trigger Event:
push
-
Statement type:
File details
Details for the file spextract-0.6.4-py3-none-any.whl.
File metadata
- Download URL: spextract-0.6.4-py3-none-any.whl
- Upload date:
- Size: 18.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ba5de61aa1cc41eb0543c55f76d942f05e4a8ff3ef63837182f183963e45cec
|
|
| MD5 |
c52966cac7612e8ea61258bcee662d1c
|
|
| BLAKE2b-256 |
b931212e143fe25d8ac6db4be745100ac942de1e3e9a3c65aa4bd99a31525f8c
|
Provenance
The following attestation bundles were made for spextract-0.6.4-py3-none-any.whl:
Publisher:
ci.yml on vincentropy/declarative_scraper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spextract-0.6.4-py3-none-any.whl -
Subject digest:
6ba5de61aa1cc41eb0543c55f76d942f05e4a8ff3ef63837182f183963e45cec - Sigstore transparency entry: 1702648547
- Sigstore integration time:
-
Permalink:
vincentropy/declarative_scraper@9d6accb65c58e3c22c7ea3896a2b7232dd07c507 -
Branch / Tag:
refs/tags/v0.6.4 - Owner: https://github.com/vincentropy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@9d6accb65c58e3c22c7ea3896a2b7232dd07c507 -
Trigger Event:
push
-
Statement type: