Back to Case Studies

LLM-Guided Web Extraction

One Example from the LLM, the Rest from the Page Structure

ProductionMedia, Marketing & Language ServicesSep 2023 – Dec 2023NLP, Knowledge Systems & Generative AI
200+
Websites crawled and monitored
~0.95
Extraction accuracy
≤ 15%
Less time spent on web research
0
Site-specific rules

My Role

Role
Lead within the client's R&D team
At CHI Software
Team
Me + 2 developers, 1 QA, 2 linguists
Stage reached
In production on AKS
Key decisions
  • LLM finds one example; DOM structure finds the rest
  • Reuse my 2022 structural-homogeneity algorithm
  • Drop site-wide repeated fragments by text hashing

Approach at a Glance

Details
  1. 1Crawling
  2. 2The LLM Picks the Target
  3. 3The DOM Analyser Expands It
  4. 4Boilerplate Removal
  5. 5Indexing and Q&A over Websites
  6. 6Deployment

Executive Summary

A universal web extractor for a global language-services company. Its specialists had to keep track of what was happening on hundreds of websites: competitors' open positions, new services, changes in offerings. They did it by browsing and copying by hand, because every site is built differently and a classic scraper needs rules for each one.

The extractor combines two ideas:

  • The LLM finds one example. The user describes in plain words what they need, for example "job openings". GPT-4 reads the page and marks the content that matches.
  • The page structure finds the rest. A DOM tree analyser takes the elements the LLM marked and finds every element on the page built the same way. If the LLM found one job post, the analyser finds all the others in the list. This reuses the structural-homogeneity algorithm I designed in 2022, which then ran without any LLM.

The extracted content is cleaned, indexed in a vector database and available for question answering per site. The system covered 200+ websites with about 0.95 extraction accuracy, and cut the time a dedicated specialist spent on this research by up to 15%. I led it within the client's R&D team (two more developers, a QA engineer and two linguists), and designed and built the main modules, the deployment and the documentation myself.


Client Profile

The client is a global language-services company with an internal R&D team building AI tools for its business. One recurring need was market intelligence: knowing which positions competitors were hiring for, which new services appeared on the web, and keeping that knowledge up to date.

Why it was hard:

  • Every website is different. Hundreds of sites, each with its own markup and templates. Per-site scrapers break at the next redesign and don't scale to hundreds of sources.
  • LLMs alone are expensive and unreliable on whole pages. Sending every full page to GPT-4 and asking it to list every item costs a lot of tokens, hits quota limits, and long lists come back incomplete.
  • Pages are full of boilerplate. Headers, footers, menus and cookie banners repeat on every page and pollute both extraction and search.

Technical Approach

  1. Crawling – A breadth-first crawler collects the pages of each site up to a set limit, and a headless browser (Playwright) renders them, so content loaded by JavaScript is captured too.

  2. The LLM Picks the Target – The user describes what to extract in plain words. GPT-4 (Azure OpenAI, through LangChain) reads the page and marks the chunks that match the description. The LLM is used for what it is good at, understanding meaning, and only needs to find a representative example, not enumerate everything.

  3. The DOM Analyser Expands It – Starting from the elements the LLM marked, the DOM tree analyser finds all elements on the page with the same or a very similar structure: the same tag paths and subtree shape, with small differences tolerated. This is the structural-homogeneity algorithm from my 2022 menu scraper. There it had to guess which repeated block mattered. Here the LLM tells it, so the two together are both accurate and complete. The key decision was this split: the LLM for meaning, the structure for coverage. It keeps the LLM calls short and cheap, and the result doesn't depend on the LLM listing every item.

  4. Boilerplate Removal – Text fragments that repeat across the whole corpus of a site, like headers, footers and navigation, are detected by hashing normalised text and removed. Known boilerplate elements can also be excluded by their ids and classes.

  5. Indexing and Q&A over Websites – The cleaned content is split into chunks, embedded with Azure OpenAI embeddings and stored in Qdrant, tagged by site. Specialists can then ask questions about one site or several, and GPT-4 answers from the retrieved chunks. Results can be exported to an Excel report with the answers, their context and the parameters used.

  6. Deployment – A Flask API for crawling and indexing, with long jobs processed through a queue worker. It is packaged in Docker, built through Azure DevOps pipelines and deployed on the team's Kubernetes cluster (AKS).


Business Outcome

The client's specialists got one tool to monitor 200+ websites without writing a rule per site: describe what you are looking for, and the system extracts it from every page and keeps it searchable. Extraction reached about 0.95 accuracy, and the time a dedicated specialist spent on web research dropped by up to 15%. The service ran on the team's Kubernetes cluster.

The project showed how an older, purely structural algorithm and an LLM complement each other. The LLM brings understanding but is costly and incomplete on long lists. The structure brings completeness but doesn't know what matters. Together, one example from the LLM is enough to extract the whole list.

Technologies

LLMsGPT-4Azure OpenAILangChainDOM Tree AnalysisWeb ScrapingPlaywrightQdrantEmbeddingsFlaskDockerKubernetes (AKS)

Planning something similar?

Tell me about it on a short call. New projects can start within 2 weeks