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
pip install listract
Requires Python 3.9 or newer.
For browser-rendered pages:
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
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
License
MIT