A gigabytes fast HTML parser and selector, powered by Rust and SIMD.
Parsing has been a huge bottleneck for large-scale web crawlers. simdhtml brings native SIMD speed to the HTML extraction pipeline—10x faster than parsel, the scrapy default.
- Fast: Over 4000 page/s/core in real-world workloads, 7x-150x faster than commonly used parsers.
- Drop-in Replacement: Migrate from parsel by changing a single line of code.
- Standards: 98% WPT conformance in spec mode, while remaining significantly faster.
- Automatic: Adapt to available CPU features at runtime. No configuration needed.
- Reliable: Built in Rust, with
unsafestrictly confined to low-level SIMD intrinsics.
Python Docs · Rust Docs · Installation · Usage · Benchmarks
uv add simdselfrom simdsel.parsel import Selector
html = '<div class="item" data-id="1"><h2>First & best</h2><a href="/one">one</a></div>'
sel = Selector(text=html)
sel.css(".item h2::text").get() # 'First & best'
sel.css("a::attr(href)").get() # '/one'
sel.xpath("//div/@data-id").get() # '1'The Python documentation covers the full selector API, the XPath subset and Scrapy integration.
cargo add simdseluse simdsel::Selector;
fn main() -> Result<(), simdsel::Error> {
let sel = Selector::from_text(
r#"<div class="item" data-id="1"><h2>First & best</h2></div>"#,
)?;
assert_eq!(sel.css("h2::text")?.get(), Some("First & best".into()));
assert_eq!(sel.xpath("//div/@data-id")?.get(), Some("1".into()));
Ok(())
}Rust users can start at docs.rs/simdsel.
We use xtask for automating chores.
# test parsel compatbility
cargo xtask compat --parsel
# data management
cargo xtask data
cargo xtask data --clear
# corpus tests (need `cargo xtask data`)
cargo test --release -p simdhtml-tests -- --ignored
cargo test -p simdhtml-tests --features quick -- --ignored
# sampled benchmark for fast iteration
cargo xtask bench --quick
# benchmark compared with other parsers
cargo xtask bench --compare
# plot performance graph
cargo xtask plot- More bindings: JS/C/CLI/Go
- Query aware parser: do not pay for unnecessary parsing
- Mutable support: so that we can support bs4 and dom like api
- GPU: large scale, offline analysis, but not of priority
MIT or Apache 2.0 at your option.