HTML List Extraction¶
The list tool extracts ordered, unordered, and definition lists from HTML pages and writes them to CSV or JSON.
Supported sources¶
extract_lists and scrape lists accept:
a local HTML file path
an HTTP or HTTPS URL
Supported list types¶
Tag |
Description |
|---|---|
|
Unordered list — one item column in CSV |
|
Ordered list — one item column in CSV |
|
Definition list — |
Nested lists are flattened: only the text of the outer list item is kept.
Output model¶
Each list becomes one record:
HtmlListforul/ol— holds a flatitems: list[str]HtmlDefinitionListfordl— holdsitems: list[dict[str, str]]where each dict hastermanddescriptionkeys
Example JSON output:
[
{"tag": "ul", "items": ["Alpha", "Beta"]},
{"tag": "dl", "items": [{"term": "Python", "description": "A language."}]}
]
Output filename¶
When no output path is supplied, scrape-smith writes to a safe filename based on the source:
page.html -> page-lists.csv
If that filename already exists, a numeric suffix is added, such as
page-lists-2.csv.