Moving to Parsec
You already have a parser that works. These guides show what your code looks like after the move, task by task, and say plainly where the library you have now is still the better pick.
| You use | From | What changes |
|---|---|---|
| selectolax | Python | One import. The API is selectolax’s; a few calls behave differently, and a few aren’t there yet. |
| Beautiful Soup | Python | find_all() becomes CSS selectors or XPath, and the tree becomes the one a browser builds. |
| lxml.html and XPath | Python | Your XPath moves as it is. .text and .tail become text nodes. |
| html5ever, scraper, kuchikiki | Rust | The same tree. Element references become node ids you read through the document. |
| Lexbor | C | Pointers become node numbers. The guide maps each lxb_ call to Parsec’s, C and Rust. |
What every guide has
A table of what maps to what, then the same jobs done both ways: reading a listing, cleaning a page, editing it, decoding bytes, sharing it between threads. In the Python and Rust guides every example runs, the old library’s half against its current release and Parsec’s against the one on PyPI and crates.io, so neither side is a sketch. None of them promises a drop-in swap. Even selectolax, whose API Parsec copies, has differences worth reading before you change the import.
Is it worth it?
On speed, it depends on what you’re moving from. In Rust, on 13 real pages, Parsec parsed 362 MB/s, Lexbor 242 and html5ever 83. Over 1,746 pages from a real crawl, html5ever’s process peaked at 92 MB to Parsec’s 101 MB, so if memory is what you’re short of, html5ever has the edge there. From Python, Parsec parses those pages 1.6 times as fast as selectolax and runs selectors 2.8 times as fast (Python speed). There’s no published comparison with Beautiful Soup or lxml, so each of those guides ends with a way to time both on your own pages, which is the number that counts anyway.
Speed isn’t the only reason. Parsec’s pages can be shared between threads, its tree is the one a browser builds, and it reads bytes in any encoding the way a browser does. The benchmarks have every figure and how it was measured.