Treeless, one-pass HTML extraction — CSS/XPath selectors matched on a streaming scan, no DOM.
Actively maintained. Last release 4 weeks ago, commits in 17 of the last 26 weeks. A safe choice.
pip install frostworkREADME as published on PyPI with version 0.2.2.
Frostwork
Fast HTML extraction for Python and Rust, without a DOM.
Frostwork compiles a set of CSS or XPath selectors and extracts their values in one scan of an HTML response. Reuse the schema across Scrapy callbacks, web-poet pages or standalone code. Working memory tracks parser state, pending matches and returned values, without storing a document tree.
Frostwork supports a focused selector subset, continuously checked against Parsel/lxml. Python rejects
unsupported selectors before scanning; strict=False requests empty columns. There is no parser fallback.
Check the compatibility contract
before migrating code that needs arbitrary tree traversal.
The benchmarks compare throughput, memory and selector coverage with Parsel, lxml and other engines, including workloads where Frostwork loses. Performance depends on page shape, selector count and output volume.
Install
Frostwork requires Python ≥ 3.10. Install the core package, or include the web-poet integration:
pip install frostwork
pip install "frostwork[webpoet]"
Published wheels contain the Rust extension, so installing from PyPI does not need a Rust toolchain. Building an editable checkout does; see the Python development guide.
Extract a named item
Build a Page once, then reuse it for each response:
from frostwork import Page
PRODUCT = (Page()
.field("name", "h1::text") # first match, or None
.field("price", ".price::text")
.field_all("images", "img::attr(src)")) # every match, or []
html = b"<h1>Widget</h1><span class=price>$9</span><img src=/a.png>"
assert PRODUCT.extract(html).to_dict() == {
"name": "Widget", "price": "$9", "images": ["/a.png"],
}
In an ordinary Scrapy callback, pass the original bytes and the response's encoding:
def parse_product(self, response):
yield PRODUCT.extract(response.body, encoding=response.encoding).to_dict()
Use field_all whenever you need every match, and to join text nodes. Without an explicit
encoding, Frostwork checks the BOM and declarations, then autodetects the encoding. For positional columns
without field names, use the .