Skip to main content

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

  1. Create a configuration file:
html-extract -t config data/config.yaml
  1. Customize the configuration to match your HTML structure

  2. 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:

📚 Shared Resources

Both CLI and Python users can access:

🚀 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

html_extract-0.7.0.tar.gz (96.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

html_extract-0.7.0-py3-none-any.whl (38.8 kB view details)

Uploaded Python 3

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

Hashes for html_extract-0.7.0.tar.gz
Algorithm Hash digest
SHA256 aeff6a244797f15535592e05b2095e6134b8e8bc1536020f44511dacf2e33778
MD5 dd8f5e2dcd130f0ad578212119a36b14
BLAKE2b-256 8136c25963a663efd00cd1753675760b9d11cc371f0cc82224a37248f7a85396

See more details on using hashes here.

Provenance

The following attestation bundles were made for html_extract-0.7.0.tar.gz:

Publisher: publish.yml on michzad/html-extract

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for html_extract-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 048d1ded938c7fe90a8bcc492f8160df8cac94c6f8c8363f43a29f8029da56ca
MD5 b3666f568699cde457f3e6e914bbc92e
BLAKE2b-256 64c12213a5ba9fa4446647d98d475204d6bb730916f238a682d415d8ed1f1bff

See more details on using hashes here.

Provenance

The following attestation bundles were made for html_extract-0.7.0-py3-none-any.whl:

Publisher: publish.yml on michzad/html-extract

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