Extract structured data from HTML files using declarative configuration files (YAML or JSON)
Project description
HTML Extract
A Python tool for extracting structured data from HTML files using declarative configuration files (YAML or JSON). No code required - define what to extract, how to find it, and how to process it, all in configuration files. Automatically detects and extracts all items from each HTML file.
Features
- Configuration-Driven: Define extraction rules in YAML or JSON files
- Multiple Extraction Types: Text, regex, contains, and metadata extraction
- Batch Processing: Process single files, directories, or CSV lists
- Multiprocessing: Parallel processing for improved performance
- Flexible Output: CSV and JSON output formats
- Dual Interface: Python API and CLI with complete feature parity
- Programmatic Configs: Create configurations from Python dict objects
Quick Start
Installation
pip install html-extract
This installs the package with all features, including the html-extract CLI command.
Basic Usage
- Create a configuration file:
html-extract -t config data/config.yaml
-
Customize the configuration to match your HTML structure
-
Extract data:
html-extract data/page.html -c data/config.yaml -k category -o output.csv
Choose Your Path
HTML Extract provides two interfaces - choose the one that fits your workflow:
🖥️ Using the Command Line?
If you prefer working with command-line tools, start here:
→ CLI Quick Start - Get started in 5 minutes
CLI Documentation:
🐍 Using Python?
If you're building Python applications or scripts, start here:
→ Python Quick Start - Get started in 5 minutes
Python Documentation:
- Installation
- Python API Guide
- Programmatic Configs
- Integration Examples
- API Reference
- Troubleshooting
📚 Shared Resources
Both CLI and Python users can access:
- Configuration Reference - Complete config guide
- Core Concepts - Understanding how it works
- Examples - Real-world use cases
- Logging Guide - Logging configuration
🚀 Advanced Topics
Example
Extract product listings from HTML:
# config.yaml
categories:
- name: products
attribute_names: [link, title, price]
attributes:
- name: link
required: true
extract:
type: regex
selector: a
extract_attribute: href
pattern: "/d/oferta/.*\\.html"
- name: title
required: true
extract:
type: text
selector: h4
extract_attribute: text
- name: price
required: false
extract:
type: text
selector: p
html_attributes:
data-testid: ad-price
extract_attribute: text
Using CLI:
html-extract data/page.html -c config.yaml -k products -o output.csv
Using Python:
from html_extract import extract_data_from_html, load_config, save_output
config = load_config('config.yaml')
df = extract_data_from_html('page.html', config, category='products')
save_output(df, 'output.csv')
Requirements
- Python 3.7+
- beautifulsoup4
- pandas
- pyyaml
Development Status
⚠️ Note: This project was created with vibe coding and is still under heavy development. Features and APIs may change. Use with caution in production environments.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
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 html_extract-0.7.0.tar.gz.
File metadata
- Download URL: html_extract-0.7.0.tar.gz
- Upload date:
- Size: 96.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aeff6a244797f15535592e05b2095e6134b8e8bc1536020f44511dacf2e33778
|
|
| MD5 |
dd8f5e2dcd130f0ad578212119a36b14
|
|
| BLAKE2b-256 |
8136c25963a663efd00cd1753675760b9d11cc371f0cc82224a37248f7a85396
|
Provenance
The following attestation bundles were made for html_extract-0.7.0.tar.gz:
Publisher:
publish.yml on michzad/html-extract
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
html_extract-0.7.0.tar.gz -
Subject digest:
aeff6a244797f15535592e05b2095e6134b8e8bc1536020f44511dacf2e33778 - Sigstore transparency entry: 798770205
- Sigstore integration time:
-
Permalink:
michzad/html-extract@b6d7a7ba0d2c39727b980ef1fbfdb931ee8ea866 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/michzad
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b6d7a7ba0d2c39727b980ef1fbfdb931ee8ea866 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file html_extract-0.7.0-py3-none-any.whl.
File metadata
- Download URL: html_extract-0.7.0-py3-none-any.whl
- Upload date:
- Size: 38.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
048d1ded938c7fe90a8bcc492f8160df8cac94c6f8c8363f43a29f8029da56ca
|
|
| MD5 |
b3666f568699cde457f3e6e914bbc92e
|
|
| BLAKE2b-256 |
64c12213a5ba9fa4446647d98d475204d6bb730916f238a682d415d8ed1f1bff
|
Provenance
The following attestation bundles were made for html_extract-0.7.0-py3-none-any.whl:
Publisher:
publish.yml on michzad/html-extract
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
html_extract-0.7.0-py3-none-any.whl -
Subject digest:
048d1ded938c7fe90a8bcc492f8160df8cac94c6f8c8363f43a29f8029da56ca - Sigstore transparency entry: 798770215
- Sigstore integration time:
-
Permalink:
michzad/html-extract@b6d7a7ba0d2c39727b980ef1fbfdb931ee8ea866 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/michzad
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b6d7a7ba0d2c39727b980ef1fbfdb931ee8ea866 -
Trigger Event:
workflow_dispatch
-
Statement type: