An LLM scraper combines page retrieval with model-based interpretation; neither stage guarantees the other succeeded.
The LLM Scraper TypeScript library uses Playwright and supports schema-based extraction with Zod or JSON Schema.
Start with a narrow page and a small schema, then preserve evidence for every extracted value.
Deterministic selectors remain a useful baseline for stable fields such as a product title or identifier.
Nstdata Crawl can supply managed, LLM-ready page content when operating browser workers becomes a separate engineering problem.
Measure accepted-record cost, unsupported values, and incomplete pages before expanding the URL list.
What is an LLM scraper, and when is one useful?
An LLM scraper is a workflow that uses a language model to interpret retrieved web content and return fields or summaries that match a requested task.
βLLM scraperβ also refers to specific software. This guide uses the TypeScript LLM Scraper project for a concrete example, while separating its responsibilities from managed collection through Nstdata Crawl.
A model is useful when several page templates describe the same concept differently. For example, product availability might appear as a sentence rather than a uniform machine-readable attribute. The model can interpret that sentence, but it cannot recover a page that was never retrieved or infer a missing identifier responsibly.
Prefer ordinary parsing for stable structures that already expose your fields. Introduce semantic extraction for the parts where interpretation changes the result. This creates a testable baseline and reduces the amount of content sent to a model.
How does LLM Scraper turn a page into structured data?
LLM Scraper turns a browser page into model input and requests structured output according to a supplied schema.
The LLM Scraper repository documents a Playwright-based TypeScript library, multiple input representations, and schema-based output. Its current examples use the AI SDK's interface. Old examples using a different call shape should be checked against the installed release.
Playwright navigates to the page and executes browser code. A locator wait can establish that a required element exists before extraction. That wait is more meaningful than assuming the first network response contains all data.
The Playwright locator guide explains how locators and their waits work. A selector is still specific to the page template; inspect it when the source changes.
The model supplies a candidate interpretation
The model receives the representation chosen by the application and attempts to populate the schema. A type-correct object can still contain the wrong product identifier or a value from a recommendation card. Schema validation must be followed by source and business checks.
The JSON Schema object reference is useful when defining required fields and additional-property rules. Type constraints alone do not prove the meaning of an extracted value.
What do you need before running this tutorial?
You need a supported Node.js environment, Playwright with its browser installed, the LLM Scraper dependencies, and a model-provider account for the model step.
The example uses Books to Scrape, a public scraping sandbox. Its catalog values are demonstration data rather than real market evidence. Collect one page for the first run.
Parameter
Purpose
Target URL
The exact permitted product detail page
OPENAI_API_KEY
Private credential used by this example's model provider
LLM_MODEL
A model identifier currently available to your account
Schema
Title, UPC, availability text, and supporting evidence
Readiness selector
.product_main h1 for this sandbox template
Output file
A reviewable candidate record
The browser handshake and library interfaces were checked for this guide. The model request below is a credential-dependent example: no model key was available in the verification environment, so no model-generated output is presented as a live result.
How do you build a small LLM Scraper workflow?
Build a small LLM Scraper workflow by verifying browser content first, then running a schema-constrained model request with explicit acceptance checks.
Method 1: Use the browser library directly
Step 1: Install the dependencies
In a Node.js project, run:
npminstall llm-scraper@2.0.0 playwright zod ai @ai-sdk/openai
npx playwright install chromium
Keep your lockfile with the application. These commands install libraries and a browser, not a model account. Provider usage is a separate prerequisite and cost.
Step 2: Configure model access
Set OPENAI_API_KEY through your shell or secret manager and set LLM_MODEL to an available model identifier. Keep both the generated credentials and populated configuration outside source control. Merely creating a .env file does not load it unless your application does so.
Step 3: Run one extraction
Save the following as extract.mjs and run node extract.mjs. This is the credential-dependent model step; it was not executed against a paid model during verification.
import{ chromium }from'playwright';import{ z }from'zod';import{Output}from'ai';import{ openai }from'@ai-sdk/openai';importLLMScraperfrom'llm-scraper';import{ writeFile }from'node:fs/promises';if(!process.env.OPENAI_API_KEY||!process.env.LLM_MODEL){thrownewError('Set OPENAI_API_KEY and LLM_MODEL');}const url ='https://books.toscrape.com/catalogue/'+'a-light-in-the-attic_1000/index.html';const schema = z.object({title: z.string().min(1),upc: z.string().min(1),availability: z.string().min(1),evidence: z.string().min(1).describe('Exact short source text supporting the availability value'),});const browser =await chromium.launch();try{const page =await browser.newPage();await page.goto(url,{waitUntil:'domcontentloaded'});await page.locator('.product_main h1').waitFor();const visibleTitle =await page.locator('.product_main h1').innerText();const sourceText =await page.locator('body').innerText();const scraper =newLLMScraper(openai(process.env.LLM_MODEL));const{ data }=await scraper.run( page,Output.object({ schema }),{format:'html'});const record = schema.parse(data);if(record.title!== visibleTitle ||!sourceText.includes(record.upc)||!sourceText.includes(record.evidence)||!sourceText.includes(record.availability)){thrownewError('Source verification failed');}awaitwriteFile('candidate.json',JSON.stringify({...record,source_url: url,observed_at:newDate().toISOString()},null,2));}finally{await browser.close();}
The direct browser check retrieved the title βA Light in the Atticβ and the product-information table. Those are observed page facts. A later model result should be compared with that evidence rather than treated as correct because the code returned an object.
Step 4: Review the candidate record
Open candidate.json and compare its identifier and availability with the product detail area. Exact text membership is a basic safeguard; it does not establish that a value belongs to the correct semantic field. A production validator should confirm that the UPC came from the product's UPC row.
Method 2: Use Nstdata Crawl as the collection layer
Step 1: Connect managed collection
Add the hosted Crawl MCP endpoint https://mcp.nstdata.io/crawl to a compatible client and authorize. Use the Nstdata MCP integration guide to choose hosted or local setup.
Step 2: Retrieve one product page
Use this prompt in the connected agent:
Read the Books to Scrape A Light in the Attic product detail page with
Nstdata Crawl as Markdown. Submit once and read any returned reference.
Extract title, UPC, and availability only from the main product area.
Return source text for each field. Use null if a field is missing.
Do not use related products, infer stock, or follow additional URLs.
In the managed collection test, the returned Markdown included the title and a product-information table containing the UPC and availability. The task returned its content through a reference that was retrieved before inspection.
Step 3: Validate the extraction downstream
Apply the same schema and semantic acceptance checks used for the browser-library path. The managed collector and the model extraction library are alternative components with different interfaces; the prompt above does not claim a native adapter between them.
What does Nstdata Crawl add to an LLM extraction pipeline?
Nstdata Crawl adds managed retrieval and format preparation so a team can focus its code on interpretation and record quality.
Nstdata Crawl is a Web Crawling API for LLM-ready data. It can retrieve one page or discover pages within explicit site boundaries. Rendering controls help wait for page content before output conversion. Standard calls use built-in proxy access without requiring separate gateway configuration. The service supplies page evidence, while your extraction layer supplies the business schema and acceptance rules.
Which outputs and controls should you choose?
Markdown for interpretation: Send a readable representation to the model and retain the URL and observation time.
HTML for deterministic parsing: Preserve document structure when table relationships or labels are important.
Visual artifacts for review: Request screenshots or PDFs when a human must inspect the page state.
Links and recursive discovery: Collect a bounded set of relevant pages using page and depth limits.
Task operations: Resume submitted tasks and retrieve stored artifacts before producing a report.
The Crawl billing model covers collection usage. Include model input, model output, browser operation in the library path, and review effort in the overall budget. Compare both approaches using the same acceptance rules, as described in the web data vendor checklist.
Why can an LLM scraper return plausible but wrong records?
An LLM scraper can return plausible but wrong records when the page is incomplete, the prompt is ambiguous, or the model selects evidence from the wrong part of the document.
Failure
Diagnostic clue
Correction
Wrong product title
Title belongs to a related card
Restrict the content region and validate the main heading
Invented identifier
Identifier has no supporting source text
Permit null and reject unsupported values
Invalid object
Schema parsing fails
Validate output and retain a redacted failure sample
Missing content
Browser shows a loading shell
Wait for a task-specific selector
Cost growth
Long pages or repeated calls
Reduce input scope and cache approved source artifacts
Duplicate records
Same page appears under multiple links
Normalize identity before storage
Treat page instructions as untrusted content. A product description should not be able to instruct the agent to read secrets or change its output destination. Keep source text separate from workflow instructions and permit only the tools needed for the task.
How should you move an LLM scraper into production?
Move an LLM scraper into production by turning a successful example into a measured pipeline with test pages, explicit rejects, and recoverable state.
Keep a deterministic baseline for stable fields, a model version and prompt version for semantic fields, and a reviewed evaluation set. The structured data extraction guide provides additional selection context. Start with one page template before expanding. For workflows needing full interactive browser ownership, evaluate Nstdata Cloud Browser separately from managed page collection.
An LLM is not required for all web scraping. Stable HTML, JSON-LD, or approved APIs can often be parsed deterministically.
Q: Does a schema prevent hallucinations?
A schema constrains output structure and types, but it does not prove factual correctness. Validate evidence and field meaning against the source.
Q: Was the model extraction in this guide run live?
The model extraction was not run live because no model-provider credential was available. Browser retrieval, library interfaces, and the separate Nstdata Crawl content path were checked.
Q: Can Nstdata Crawl return the final business schema automatically?
The demonstrated Crawl workflow returns page representations that a downstream extractor interprets. Do not assume that a Markdown or HTML response already matches your business schema.
Q: When should I stop retrying extraction?
Stop retrying when the source is unavailable, access is not authorized, or required evidence is absent. Model retries should have an explicit limit and a recorded reason.
Lena Zhou
Nov. 26th 2026
Experience Nstproxy Crawl - Start Your Free Trial Today
Crawl entire websites with a single API request
Turn any website into Markdown, HTML, JSON, links, PDFs and more β without managing crawling infrastructure.