Skip to content

episcraper: web extraction that writes its own code

Krishan Marco Madan2 min readEngineering

Short answer

episcraper is a URL-to-content service. It fetches pages with plain requests or a real browser, extracts structured data with an LLM, then learns small sandboxed scripts for each kind of page, so the next pages of the same kind are extracted without the LLM, faster and for a fraction of the cost.

Many of our products start from data that lives on someone else's website: a supplier catalogue, a list of events, a page of prices. Getting it out reliably is harder than it looks, so we built episcraper, a service that takes a URL and returns clean content plus the structured fields the caller asks for.

Why an LLM alone is not enough

An LLM is very good at reading a page it has never seen and pulling out the fields you describe. It is also slow, expensive at volume and not perfectly consistent: ask twice and the answers can differ. For one page that is fine. For ten thousand pages of the same site it is the wrong tool.

episcraper uses the LLM where it shines, on pages it has not met before, and then makes it unnecessary.

Learning the shape of a site

When episcraper meets a new kind of page, for example the product pages of one shop, it records a pattern profile: which URLs match it, the structure the page is expected to have, and a small canary script that checks a fetched page really has that structure. The canary is what tells a real product page apart from a cookie wall, a challenge page or a soft block, so a bad fetch is never mistaken for an empty result.

Pages are fetched with plain HTTP requests when that is enough, and with a real browser when the page needs JavaScript to render.

Scripts that earn their place

Once the LLM has extracted the requested fields from pages of a pattern, episcraper generates an extraction script for that pattern and that set of fields, and runs it in a sandbox. From then on, pages of the same kind are extracted by the script: in milliseconds, at no model cost, with the same answer every time.

Scripts are never trusted blindly. Each one keeps a health score built from its recent successes and failures, and the healthiest are tried first. When a site changes and a script starts failing, its score drops, the LLM steps back in and a new script is learned.

Runs that survive a crash

A scrape can span many pages and many minutes. Every run is recorded step by step in a durable log, so a run that crashes or moves to another worker picks up where it stopped instead of starting over. Callers choose how strict a run is: fail on the first page that does not come back clean, or return every page that did.

The result is a scraper that gets cheaper and faster the more it is used, the opposite of what usually happens.

Share