Metadata-Version: 2.4
Name: tabulate-html
Version: 0.1.1
Summary: A robust HTML table parser for Python with full rowspan/colspan and multi-header support
Project-URL: Homepage, https://github.com/KuMaraRich/tabulate-html
Project-URL: Repository, https://github.com/KuMaraRich/tabulate-html
Project-URL: Issues, https://github.com/KuMaraRich/tabulate-html/issues
Project-URL: Documentation, https://github.com/KuMaraRich/tabulate-html#readme
Author: KuMaraRich
License: MIT
License-File: LICENSE
Keywords: colspan,crawler,data-extraction,html,lxml,parser,rowspan,table,web-scraping
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Text Processing :: Markup :: HTML
Requires-Python: >=3.8
Requires-Dist: lxml>=4.9.0
Provides-Extra: dev
Requires-Dist: black; extra == 'dev'
Requires-Dist: isort; extra == 'dev'
Requires-Dist: mypy; extra == 'dev'
Requires-Dist: pytest-cov; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Provides-Extra: docs
Requires-Dist: mkdocs; extra == 'docs'
Requires-Dist: mkdocs-material; extra == 'docs'
Description-Content-Type: text/markdown

# tabulate-html

A robust, professional-grade HTML table parser for Python, designed specifically for complex real-world web tables. It fully supports **rowspan**, **colspan**, multi-row hierarchical headers, merged cells, and concatenation of fragmented HTML snippets.

While many lightweight table parsers fail on merged cells, **tabulate-html** uses a precise 2D matrix mapping to handle them perfectly — making it an ideal choice for web scraping, data extraction, and structured crawling.

[![PyPI version](https://badge.fury.io/py/tabulate-html.svg)](https://badge.fury.io/py/tabulate-html)
[![Python versions](https://img.shields.io/pypi/pyversions/tabulate-html.svg)](https://pypi.org/project/tabulate-html/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Tests](https://img.shields.io/badge/tests-11_passed-brightgreen)](https://github.com/yourusername/tabulate-html)
[![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)](https://github.com/yourusername/tabulate-html)

[中文文档](./README.zh-CN.md)

## Features

- Accurate handling of arbitrary `rowspan` and `colspan` (outperforms pandas.read_html and most other libraries on complex tables)
- Support for multi-row hierarchical headers (automatically merged as `Level1_Level2_Level3`)
- Concatenation of multiple table fragments (perfect for paginated or dynamically loaded tables)
- Configurable extraction strategies:
  - `TEXT_AND_LINKS`: plain text + appended links/images
  - `RAW_HTML`: preserve original cell HTML
  - `STRIP_TAGS`: pure text only
- Comprehensive logging and production-ready error handling
- Full type hints and clean, maintainable code

## Installation

```bash
pip install tabulate-html

## Quick Start

```python
from tabulate_html import parse_html_tables

html = """
<table>
  <tr><th>Name</th><th colspan="2">Contact</th></tr>
  <tr><th>Age</th><th>Phone</th><th>Email</th></tr>
  <tr><td rowspan="2">John Doe</td><td>30</td><td>138...</td><td>john@example.com</td></tr>
  <tr><td>31</td><td>139...</td><td>john.new@example.com</td></tr>
</table>
"""

data = parse_html_tables(html, header_rows=[0, 1])
print(data)
```

##### Output:

```json
[
  {
    "Name_Age": "John Doe",
    "Contact_Phone": "138...",
    "Contact_Email": "john@example.com"
  },
  {
    "Name_Age": "John Doe",
    "Contact_Phone": "139...",
    "Contact_Email": "john.new@example.com"
  }
]
```

## Advanced Usage

```python
from tabulate_html import TableParser, ParseStrategy

parser = TableParser(
    strategy=ParseStrategy.TEXT_AND_LINKS,  # Extract text and append links/images
    key_separator="-",                      # Use hyphen for header keys
    tag_separator=" "                       # Join multi-text segments with space
)

result = parser.parse(html_snippets, header_rows=[0, 1, 2])  # Support 3-level headers
json_output = parser.to_json(result)
```

