Metadata-Version: 2.4
Name: listract
Version: 0.1.1
Summary: Cross-language structural list extraction with a shared JSON model
Author: isesword
License: MIT
Project-URL: Homepage, https://isesword.github.io/Listract/
Project-URL: Repository, https://github.com/isesword/Listract
Project-URL: Documentation, https://github.com/isesword/Listract#readme
Project-URL: Issues, https://github.com/isesword/Listract/issues
Keywords: list extraction,html,scraping,dom,structural analysis
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
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 :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Text Processing :: Markup :: HTML
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: lxml>=6.1
Requires-Dist: requests>=2.32
Provides-Extra: browser
Requires-Dist: playwright>=1.60; extra == "browser"

# Listract

**Listract = List + Extract.** Structural list extraction from raw HTML: decide whether the page is a list, identify the main list container, and return cleaned entries as one shared JSON model.

The Python package bundles the extraction model. No separate model download is required.

## Install

```bash
pip install listract
```

Requires Python 3.9 or newer.

For browser-rendered pages:

```bash
pip install "listract[browser]"
```

The optional browser extra requires `playwright>=1.60`. On Python 3.9 pip resolves Playwright 1.60; Python 3.10+ resolves current Playwright releases.

## Quickstart

```python
from listract import ListExtractor

html = open("page.html", encoding="utf-8").read()

extractor = ListExtractor()
result = extractor.extract_html(
    html,
    "https://example.com/list",  # replace with the page URL the HTML came from
)

print(result["status"])                  # list / no_list
print(result["production"]["action"])    # fast_list / review / slow_no
print(len(result["entries"]))            # cleaned list entries
```

`ListExtractor()` loads the bundled model from inside the wheel. Set `LIST_EXTRACT_MODEL_DIR` only when overriding it with a custom model.

## What it returns

Listract returns a shared JSON contract covering:

- page-level `status` (`list` / `no_list`)
- production `action`
- the selected list container
- cleaned entries and their links
- manifest and verification helpers

## Links

- Repository: https://github.com/isesword/Listract
- Documentation: https://isesword.github.io/Listract/
- Chinese README: https://github.com/isesword/Listract/blob/main/README.zh-CN.md
- Issues: https://github.com/isesword/Listract/issues

## License

MIT
