duzun/hquery
hQuery is a fast, lightweight PHP HTML/XML parser with a jQuery-like API. It supports CSS selectors and DOM traversal, has no external dependencies, and handles broken or incomplete HTML gracefully, making web scraping, content extraction, and HTML manipulation simple and memory-efficient.
Adopt when:
ext-dom/libxml tuning.:first, :eq, attribute operators) and map cleanly onto a jQuery-style mental model your frontend engineers already have.Look elsewhere when:
:nth-child chains, pseudo-elements, and edge-case selector semantics will surprise you. Symfony DomCrawler + CssSelector, or DOMDocument + XPath, is the safer choice for standards-critical work.To executives: This is a small, MIT-licensed, zero-dependency PHP library that turns raw HTML into structured data very quickly. It lets us build web-data ingestion features — price monitoring, supplier catalogue import, content migration, HTML report parsing — without per-request fees to a scraping vendor and without adding third-party code to our supply chain. The cost is engineering time, not licence spend, and the risk is contained: it is a utility we can swap out behind a thin internal interface if it stops being maintained.
To engineering: It is a jQuery-style selector engine for HTML in PHP — no Composer dependencies, PHP 5+, extremely fast on megabyte-scale documents, and familiar to anyone who has written front-end selectors. It covers the practical CSS selector subset most scrapers actually use and gives you attribute/text extraction directly. It deliberately does not do HTTP, JavaScript rendering, proxies, or the full CSS3 spec, so we pair it with our existing HTTP layer and keep a headless browser for JS-heavy targets. Recommend wrapping it behind an internal HtmlExtractor interface so we are not coupled to it, pinning the version, and fuzzing it against hostile markup before it touches customer input.
How can I help you explore Laravel packages today?