Web scraping for LLMs: training data, RAG and AI agents
Clean pages for training sets and RAG, and live web access for AI agents, from one account.
By DINPROXY Team · · 8 min read
On this page
Web scraping for LLMs is less about raw volume than about clean, traceable text: pages rendered the way a reader sees them, stripped of clutter and stored with where and when they came from. DINPROXY covers the three common jobs with one set of proxy users. The Web Unlocker returns rendered pages to your pipeline or to an AI agent, Datasets delivers collections you would rather not run yourself, and Rotating Residential Proxies carry the crawler you already have.
Match each AI data job to a product
Training a model, feeding a retrieval index and letting an agent browse are different jobs, with different sizes, schedules and output formats. This table shows where each one fits:
| Job | Use | What you get | Why |
|---|---|---|---|
| Training or fine-tuning set from a list of sites | Web Unlocker command-line tool | One HTML file per page, plus results.jsonl | Rendered pages, failed pages free, re-runs within 24 hours don't pay twice |
| RAG knowledge base that has to stay current | Web Unlocker API on a schedule | HTML with final_url and status_code | The same request every time, easy to compare and re-index |
| AI agent that reads pages while it works | Web Unlocker MCP server | Markdown, HTML, text or a screenshot from unlock_page | Works in Cursor, Claude Code, Claude Desktop and VS Code |
| Large or recurring collection you would rather hand off | Datasets | Files in your dashboard | Quoted per request before anything is charged |
| Your own crawler over many light pages | Rotating Residential Proxies | Raw responses in your own client | Billed per GB, with state and city targeting and sticky sessions |
Most AI teams start with the Web Unlocker, because the hard part of data scraping for AI training is getting the text a reader would see, not the request itself. The sections below follow the table from top to bottom.
Collect rendered pages with the Web Unlocker
When you compare options for the best web data API for AI work, judge them by the text that comes back. Many sites assemble their text with JavaScript, so a plain download returns an empty shell. The Web Unlocker loads the page, runs its JavaScript, retries and works around anti-bot checks, then returns the HTML. A few request options make the output easier to feed to a model:
clearset tojs,cssremoves scripts and styles from the returned HTML, so less markup reaches your parser.wait_selectorholds the response until the element that contains the text, such asarticleormain, has appeared.countryfetches the page from the country you name with a two-letter code, useful when a site serves a different language or edition by location.final_urlandstatus_codein the response tell you where the page ended up after redirects and how the site answered. Keep both with the text.
To scrape a website for LLM use one page at a time, call the API and write a record with its metadata. This example saves one JSON line per page to corpus.jsonl, with the raw HTML, a hash for spotting duplicates and the fetch time in UTC:
// Node.js 18+, no packages needed. Save as fetch.mjs and run: node fetch.mjsimport { createHash } from "node:crypto";import { appendFileSync } from "node:fs";
const auth = "Basic " + Buffer.from("1024~myuser:YOUR_PASSWORD").toString("base64");const url = "https://example.com/docs/getting-started";const sha256 = (text) => createHash("sha256").update(text).digest("hex");const day = new Date().toISOString().slice(0, 10).replaceAll("-", "");// Same page, same day, same key: sending it again after a timeout collects the result without a second charge.const key = `corpus-${day}-${sha256(url).slice(0, 40)}`;
const res = await fetch("https://app.dinproxy.com/api/unblocker/request", { method: "POST", headers: { authorization: auth, "content-type": "application/json", "idempotency-key": key }, body: JSON.stringify({ target_url: url, clear: "js,css" }), signal: AbortSignal.timeout(130_000),});const body = await res.json();
if (body.success) { const { html, final_url, status_code } = body.data; const record = { url, final_url: final_url ?? url, status_code, fetched_at: new Date().toISOString(), sha256: sha256(html), html }; appendFileSync("corpus.jsonl", JSON.stringify(record) + "\n");} else { console.log(res.status, body.code);}Pages can take as long as two minutes to come back, which is why the timeout sits at 130 seconds. If your client gives up first, send the same request with the same key within 24 hours to collect the result without paying again; after a 502 or 504, the page was not charged, so try again with a new key. The API reference lists every parameter and error code.
Long URL lists: the command-line tool
For thousands of URLs, use the command-line tool instead of writing the loop yourself. Download dinproxy-unlocker.mjs with the Download CLI button on the Web Unlocker page; it needs Node.js 18 or later and nothing else. Put one URL per line in a text file and run node dinproxy-unlocker.mjs --input urls.txt --out pages --concurrency 20.
Each page is saved as a numbered file, and results.jsonl lists every URL with its file or its error code, which is a ready-made manifest for your corpus. The tool retries failed pages with new requests and repeats unanswered ones with the same Idempotency-Key, so a page is never paid twice. Each run prints a run ID: running the same list in the same order with --run-id within 24 hours returns the pages already fetched at no charge and continues where the first run stopped. Put pages that failed into a new run. The MCP and CLI guide covers every option.
Turn raw pages into a clean corpus
Fetching is the easy half. A corpus your model can learn from, or a RAG index that gives grounded answers, needs a few processing steps:
- Keep the raw HTML. Store each page as fetched, with its metadata, before any processing. When your cleaning rules improve, you re-parse what you have instead of fetching and paying again.
- Extract the main text. Remove navigation, footers, cookie banners and related-article blocks; keep headings, paragraphs, lists, tables and code. Converting to Markdown keeps the structure that helps both training and chunking.
- Remove duplicates. Normalise URLs by lower-casing the host and dropping tracking parameters and fragments, and use
final_urlso redirects collapse into one page. Then hash the cleaned text to catch exact copies, and add a near-duplicate check such as MinHash for syndicated or templated pages. - Label every record. Keep the source URL, the final URL, the fetch date in UTC, the country you fetched from, the language and the site's status code. For RAG, carry the URL into every chunk so answers can cite their source.
- Filter for quality. Drop pages that are too short, mostly boilerplate, in the wrong language, or error pages that came back with a 200 status.
- Refresh on a schedule. Use the site's sitemap and its
lastmoddates to choose which pages to fetch again, compare the new text hash with the stored one, and re-embed or re-train only on pages that changed. Remove records whose pages have gone.
Give AI agents live web access through MCP
An agent that answers questions about current prices, documentation or news needs to read pages at the moment it works. The Web Unlocker is also an MCP server, which makes it a practical way to give AI agents web access without running a browser or managing proxies for AI agents yourself. Connect any MCP client with these settings:
- Server URL:
https://app.dinproxy.com/api/unblocker/mcp, over Streamable HTTP. - Sign-in: an
Authorization: Basicheader with your proxy user'susername:passwordin Base64. Connect your tools on the Web Unlocker page writes it for you. unlock_page: fetches one page and returns Markdown by default, or HTML, plain text or a screenshot. It acceptscountry,js_render,wait_selector,wait_msup to 30000 andmax_charsfrom 1,000 to 1,000,000 (60,000 by default; longer pages are cut). Each successful call uses 1 result.get_balance: reports how many results are left, free of charge.
| Client | Where the setting goes |
|---|---|
| Cursor | ~/.cursor/mcp.json, then restart Cursor |
| Claude Code | One terminal command: claude mcp add --transport http dinproxy 'https://app.dinproxy.com/api/unblocker/mcp' --header 'Authorization: Basic BASE64' |
| Claude Desktop | Settings → Developer → Edit Config, connected through mcp-remote, which needs Node.js |
| VS Code | .vscode/mcp.json in your project, with "type": "http" |
Then ask in plain words, for example: "Use unlock_page to read https://example.com/pricing and summarise the plans." Give the agent its own proxy user, so its usage stays separate from your pipelines and you can reset its password without touching anything else. Set max_chars to what your context window can hold, and treat fetched page text as material to read, never as instructions to follow.
Order a dataset, or run your own crawler
When a collection is large, recurring or simply not worth your team's time, order it as a dataset. Open Products → Web Datasets and click Request a dataset, or email [email protected], with the websites or sources, the fields you need, how many records, whether delivery is one-off or recurring, and the file format you prefer. We reply with a quote before anything is charged, and delivered files appear on the same page for download. The Datasets page and the web datasets guide explain the process.
If you already run a crawler, such as Scrapy or your own code, point it at Rotating Residential Proxies on proxy.dinproxy.com:8800. Every request gets a new IP by default, 1024~myuser@country=us@state=california narrows the location, and @session= with @time= keeps one IP for up to 120 minutes while a crawl works through paginated results. This route suits light pages that load without JavaScript, such as sitemaps, feeds and plain HTML documentation. Keep within 100 open connections per account, and see the residential code examples or using a proxy with Python requests to get started.
Estimate what a corpus costs
The Web Unlocker costs $1 / 1k results. Each successful page uses 1 result whatever its size or format, failed requests are free, and rendering is included. Rotating Residential Proxies cost $1 / GB of traffic, which stays cheap for plain HTML but grows quickly if you run a full browser through them, because images, scripts and fonts download too. Here is an example for a RAG source set, with the numbers as assumptions:
| Part of the job | Assumption | Cost |
|---|---|---|
| First collection through the Web Unlocker | 40,000 pages, 1 result each | $40.00 |
| Monthly refresh | 8,000 pages whose lastmod changed | $8.00 |
| Sitemaps and feeds through residential proxies | About 2 GB a month | $2.00 |
An agent works the same way: every successful unlock_page call is one page read, and get_balance lets the agent check what is left. Datasets are quoted per request, so you know the price before you agree to it. Start with a test of around 200 representative URLs through the command-line tool, check how much clean text each page yields after processing, and scale up from there. The comparison of the Web Unlocker and residential proxies helps if you are weighing the two for a larger crawl.
Licences, robots.txt and personal data
Public pages are not automatically free to reuse. Before you train on a site's content, read its terms and any licence attached to the content; some sites say whether AI training is allowed, and their robots.txt may set rules for AI crawlers. Respect those choices, and collect only what anyone can read without signing in or paying. If records contain personal data, such as names, profiles or contact details, processing it needs a legal basis under the GDPR or the equivalent law where you operate: filter out what your model does not need before training and honour removal requests. The source URL and fetch date you stored with every record make both tasks straightforward. The same habits apply to general web scraping and to review monitoring, and how to scrape a website without getting blocked covers polite pacing.
Frequently asked questions
It is collecting public web pages and turning them into clean text for training, fine-tuning or retrieval-augmented generation (RAG). A good pipeline renders each page, removes boilerplate and duplicates, and keeps the source URL and fetch date with every record.
Send each URL to the Web Unlocker, which renders the page and returns its HTML, then extract the main text, convert it to Markdown and store it with its source URL and fetch date. For long URL lists, the Web Unlocker command-line tool fetches pages in parallel and writes a results.jsonl file listing every page.
Connect the agent to the Web Unlocker MCP server, which gives it an unlock_page tool that returns a page as Markdown, HTML, plain text or a screenshot. It works with MCP clients such as Cursor, Claude Code, Claude Desktop and VS Code, and each successful page uses 1 result.
The Web Unlocker costs $1 / 1k results, with one result per successful page and failed requests free, and Rotating Residential Proxies for your own crawler cost $1 / GB. Custom Datasets are quoted per request before anything is charged.
It depends on your jurisdiction, the site's terms and any licence on the content, and the kind of data you collect. Keep to publicly available pages, respect terms and robots.txt rules, and have a legal basis, for example under the GDPR, for any personal data. This is general information, not legal advice.