LLM-Assisted Extraction vs Rule-Based Parsers
The trade-offs between LLMs and rules depend on layout variability, volume, latency.

Developers keep asking whether LLMs beat rule-based parsers, but that question has no fixed answer because it's the wrong one. What matters is which trade-offs a given pipeline can absorb: layout variability, volume, latency budget, and maintenance capacity. Changing any one of those four changes the right answer with it. A systematic review of LLMs applied to web scraping and crawling found that 84% of research on this integration appeared in 2024 and 2025 alone. Most practitioners are still forming their intuitions about a landscape that barely existed two years ago. Rule-based parsers and LLM-assisted extraction both still run in production today, and neither one has pushed the other out. That alone makes the choice situational, not a contest with a permanent winner. The rest of this piece treats layout variability, volume, latency, and maintenance cost as the four variables to track, because they're the ones that actually decide which tool belongs in a given pipeline.
How rule-based parsers work
A selector doesn't need to understand what a price or a headline means, just where that value lives in the DOM, every time, on every page it's pointed at.
That positional contract is what makes rule-based parsing fast and cheap. On a stable, well-structured site, a selector runs in microseconds, costs nothing beyond ordinary compute, and returns exactly the value it was written to find. No inference call, no model latency, no ambiguity about the output format.
The Fundus library shows how far this can go at scale: manually curated, publisher-specific rules achieve high extraction accuracy across news sites, because each rule set encodes how that one publisher structures its pages. The catch sits in the word "each." Every new publisher needs its own configuration, written and tested against that site's particular markup.
The operational profile of rule-based parsing comes down to four things: low per-page cost, deterministic output, easy auditability, and zero dependency on a model's inference. What doesn't scale as cleanly is the maintenance side. The burden grows with the number of distinct site structures a pipeline has to track, not with the number of pages it processes.
Where rule-based parsers break down in practice
A site redesign, new class names, restructured divs, content that only renders after JavaScript runs, any of these can break a positional selector. Sometimes it fails loudly with an error. Sometimes it just fails quietly: it returns nothing, or the wrong field, until someone notices. Either way, a human has to step in and fix the rule before the pipeline works again.
The systematic review names HTML complexity as one of the major challenges facing extraction research. The NeuScraper paper gets more specific: modern pages increasingly rely on dynamic rendering and inconsistent markup, and static rules have no way to adapt to that on their own. NeuScraper's authors also point out that raw HTML mixes advertisements, banners, hyperlinks, and other non-content elements in with the material a pipeline actually wants, and separating signal from noise gets harder as page complexity rises. Rule-based scrapers run on fixed positional logic, so they have no way to make that judgment call.
A team doesn't pay the maintenance cost once and move past it. Every layout change restarts the same cycle: inspect the broken selector, rewrite it, test it against the new structure, deploy the fix. For a pipeline tracking one site, that cycle is manageable. For a pipeline that has to cover many domains, not just one well-known site, the per-domain configuration cost compounds. The per-domain configuration cost can eventually surpass what a more flexible extraction approach would have cost from the start.
How LLM-assisted extraction works mechanically
The mechanism behind LLM-assisted extraction runs in four steps: fetch the page, convert the raw HTML into clean Markdown or a pruned DOM that strips out boilerplate, pass that cleaned content to a language model along with a target schema, and get structured JSON back.
Instead of navigating to a fixed position, the model reads the page for meaning. It identifies what each block of content is, the way a person skimming the page would, and maps that understanding onto the fields in the schema rather than relying on where those fields happen to sit in the markup.
Structured output, things like JSON mode, function calling, and tool use, is now standard across the major LLM providers. That's what makes this approach practical at all: a developer defines a schema once, and the model fills it in reliably instead of producing free-form text that needs separate parsing.
XPath Agent shows a hybrid version of the same idea. Rather than having the model extract data directly, it uses a two-stage pipeline, a weaker model to pull out target information and cue text, a stronger model to turn that into an XPath query, so the LLM's job is writing the selector, not running it. The selector still does the extraction at runtime. The LLM just removes the human labor of authoring it by hand.
None of this works well on dirty input. NeuScraper's research demonstrates that cleanly separating primary content from boilerplate before using it downstream produces measurably better results. Clean Markdown in, usable structured data out. Raw HTML in, with its ads and navigation and tracking scripts still attached, and the output degrades accordingly.
The real cost and accuracy trade-offs of LLM extraction at scale
LLM extraction isn't free in the way a selector is. You pay somewhere between $0.001 and $0.01 in inference per page, depending on the model and how long the content is, plus whatever latency that inference call adds. For high-volume, price-sensitive pipelines, that per-page cost favors selectors even when the selectors themselves are more expensive to maintain over time.
Choosing an LLM doesn't guarantee accuracy either. The systematic review lists token limits, computational cost, and data bias as persistent challenges in LLM-based extraction, and none of those go away just because the model understands semantics instead of position.
Practitioners often blur two separate problems here, so it helps to pull them apart. Getting a model to return syntactically valid JSON, the right braces, the right keys, the right types, is largely solved for common schemas through constrained decoding, though complex schema features and tokenization edge cases still trip things up. Getting the values inside that JSON to be semantically correct is a different, harder problem, and constrained decoding does nothing to solve it. A perfectly formatted JSON object can still contain a wrong price, a mismatched date, or a headline pulled from the wrong section of the page.
Scale changes how much any of this matters. At low page volumes, inference cost barely registers. At high volumes, that same per-page cost becomes a real line item, one that reshapes the build-versus-buy math for the whole pipeline.
The four variables that determine which approach fits a given pipeline
Layout variability drives the decision more than any other factor. A pipeline covering many domains with inconsistent structure runs into a per-domain maintenance cost for rule-based parsing that keeps climbing until LLM extraction ends up cheaper overall. A pipeline with a handful of stable, known targets tilts the other way, since selectors win on cost when there's little structure to adapt to.
Volume and inference cost pull against each other, and the pattern is predictable. At low page counts, you can afford LLM extraction even for the simplest cases, because the total inference spend stays small. At high page counts, that same per-page cost becomes the actual budget constraint, and a selector running in microseconds with no inference call attached is structurally cheaper no matter how well-maintained it is.
Latency tolerance puts a hard ceiling on how much LLM extraction a pipeline can use. Anything that needs results in under a second per page, real-time price monitoring, a live agent tool call waiting on a response, is limited in how much inference it can afford to run per request.
Maintenance capacity is organizational. A small team without a dedicated scraper engineer absorbs the cost of LLM inference more easily than it absorbs an ongoing cycle of selector repair. A large data engineering team with existing tooling for monitoring and fixing selectors often finds the opposite is true. Industry analysis of the 2026 scraping landscape frames the practical starting point this way: lean on LLM extraction for new projects where schema flexibility matters most, and reserve selectors for high-volume, price-sensitive pipelines where the layout is already well understood.
Where hybrid pipelines outperform either approach alone
The most effective hybrid pattern doesn't use the LLM to extract data at runtime at all. It uses the LLM to generate or repair the selector once, up front, and then lets that selector run cheaply at high volume afterward. The model does the hard interpretive work a single time; the selector does the repetitive work millions of times over.
XPath Agent puts this into practice directly. Its two-stage LLM pipeline generates XPath queries from sampled pages and a natural-language description of the target field, and it matches the accuracy of a state-of-the-art XPath programming agent while cutting token usage and clock time significantly.
A second hybrid pattern splits the work by field. Known, stable fields run through rule-based extraction as the fast path, but if a field shifts in position or format across site versions, it falls back to LLM extraction. The rule-based path carries most of the volume; the LLM path handles the exceptions.
news-crawler-LM sits squarely in this space. Trained on human-validated, rule-based extractions from Fundus, it reaches the scalability of a machine-learning approach while holding onto the extraction quality that curated rules provide. That's the actual design principle behind every good hybrid: match each sub-task to the approach structurally suited to it, and compose the two rather than committing the whole pipeline to one paradigm.
How the infrastructure layer shapes which approach is practical
If you run LLM extraction in production, you need clean input reaching the model. Raw HTML carries boilerplate that eats tokens, drives up cost, and drags down output quality, so JavaScript rendering, boilerplate stripping, and Markdown conversion have to happen before extraction, not as an afterthought. Context, a web scraping API built for LLM pipelines, handles that conversion and boilerplate removal at scale, letting teams spend their effort on schema design and extraction logic.
Rule-based pipelines carry their own infrastructure burden. Selector maintenance is only one piece; proxy rotation to get past anti-bot systems, browser automation for pages that depend on JavaScript, and monitoring to catch silent breakage all have to run continuously in the background.
Industry analysis of the 2026 scraping landscape describes an anti-bot arms race that keeps escalating: TLS fingerprinting, JavaScript environment probing, behavioral analysis. That arms race adds a maintenance dimension to any self-operated scraping infrastructure, regardless of whether the extraction logic behind it is rule-based or LLM-assisted.
The operational cost of running this infrastructure in-house gets underestimated often. Compute, browsers, proxies, storage, and monitoring all cost real money and real engineering time, even when the scraping library itself is free and open-source. Context addresses this layer directly, offering a single REST API that handles JavaScript rendering, HTML-to-Markdown conversion, structured JSON extraction against a developer-defined schema, and full-site crawling. That removes the infrastructure layer from the developer's plate entirely, turning the choice between LLM and rule-based extraction into a parameter set on an API call.
Applying the decision framework: concrete scenarios mapped to approaches
A high-volume crawl of a single known domain, like a retailer's product catalog updated every night, has a stable layout and a high page count, so price sensitivity matters. Rule-based selectors are the right tool here. Monitoring is the investment to make, so breakage gets caught early.
Competitive intelligence pulled across dozens of domains with inconsistent layouts flips that logic. Layout variability is high and page count per domain is only moderate, so LLM extraction, or LLM-generated selectors, makes more sense. The maintenance cost of writing and keeping up per-domain rules would exceed the inference cost of just letting a model read each page.
A live agent tool call that needs structured data from an arbitrary, unknown URL has no stable target to write a selector against in advance. LLM extraction with a carefully specified schema is the only practical path here, and the real lever on accuracy is prompt quality and retry logic, not selector engineering.
A RAG pipeline indexing a corpus of documentation sites depends on freshness and clean content for downstream retrieval quality. A hybrid approach fits best: crawl with boilerplate removal, chunk the content with schema-guided extraction for metadata, and embed the body text separately.
A news crawl running at scale across many publishers is where news-crawler-LM's research points to a specific answer: a small model fine-tuned on high-quality, rule-based extractions generalizes well across domains without the per-page cost that a large general-purpose LLM would carry.
Schema-driven extraction for brand or product intelligence across pages that keep changing benefits from a different kind of investment. The PARSE framework shows that careful schema specification combined with retry logic cuts extraction errors substantially, and that investment goes into schema quality. Across all six scenarios, the answer traces back to the same four variables: layout variability, volume, latency, and maintenance capacity.
What a well-designed extraction API does
A bespoke pipeline locks a team into a permanent architectural decision. Once an approach is picked, the team builds the tooling around it and maintains both the extraction logic and the infrastructure underneath it indefinitely. Switching approaches later means rebuilding much of that work from scratch.
An API-first extraction layer separates the extraction strategy from the infrastructure underneath it. A developer specifies a schema, and the API handles the rendering, the cleaning, and the extraction itself, making the choice between a semantic approach and a structural one a configuration decision. For pipelines that need to cover many domains at once, this matters directly: the per-domain configuration cost of rule-based selectors compounds fast. Some teams consolidate on a single extraction API that handles layout variability across sites programmatically instead of maintaining a growing pile of domain-specific rules.
Industry analysis describes the 2026 stack moving toward AI-assisted selector generation, vector stores for scraped content, and scraping tools exposed through standardized protocols, gradually replacing monolithic, bespoke pipelines built around a single fixed approach. The thread running through all of it is that data infrastructure is becoming something assembled from APIs. Context fits into that pattern as the web context layer underneath it: a single REST API that turns any URL into LLM-ready Markdown, crawls full sites, and extracts structured data against a developer-defined JSON schema, turning the decisions this piece has walked through into parameters on an API call.
The pipeline's trade-offs, layout variability, volume, latency, maintenance cost, are what a well-designed extraction API turns into something a team can manage rather than something it has to architect around from scratch.


