Crawl: the most reliable web crawler APISee what’s new
Zenrows
Talk to sales Start free

LLM web scraping for RAG and agents

LLM web scraping turns live web pages into clean Markdown or JSON a language model can read, for RAG pipelines, grounding and agent tool calls. Zenrows Fetch returns a URL as Markdown in one request, protected and JavaScript-heavy pages included, and the Zenrows MCP server lets Claude, Cursor and other agents make the same call themselves.

Updated

Sample output: one page, ready for a model
{
  "url": "https://docs.example.com/api/rate-limits",
  "fetched_at": "2026-10-17T09:14:03Z",
  "format": "markdown",
  "markdown": "# Rate limits\n\nEach API key can run 50 concurrent requests.\n\n## Retry headers\n\n| Header | Meaning |\n|---|---|\n| Retry-After | Seconds to wait before the next call |\n\nSee [Errors](https://docs.example.com/api/errors).",
  "chunks": [
    { "id": "rate-limits#0", "heading": "Rate limits", "chars": 58 },
    { "id": "rate-limits#1", "heading": "Retry headers", "chars": 132 }
  ],
  "links": [
    "https://docs.example.com/api/errors",
    "https://docs.example.com/api/authentication"
  ]
}
Illustrative. Fetch returns the markdown string; your pipeline adds URL, timestamp and chunk ids before embedding or prompting.

What LLM web scraping is used for

LLM pipelines read the web twice: before the question, indexing pages into a vector store; during it, when a model or agent opens a page it just chose.

JobData you collectTypical sources
URL to Markdown for a prompt A page's body as Markdown, headings, tables and links kept Docs sites, changelogs, pricing pages, GitHub READMEs
RAG ingestion Markdown chunks, source URL, fetch time Developer docs, regulator guidance, standards bodies, Wikipedia
Grounding at query time Current text of the pages to cite Reuters, AP News, vendor pricing pages, government sites
Agent tool calls A scrape or extract result mid-task Any URL the agent opens
Structured context for tools Named fields as JSON Amazon product pages, company websites, Indeed job posts
Index refresh A new copy of each indexed URL, diffed with the last The same URL list, daily or weekly

Why web data breaks LLM pipelines

Most RAG and agent failures trace back to the page the model got.

A blocked request or empty shell looks normal, so the model answers from memory and nobody notices.

What it looks like

Scripts, styles and class names eat the token budget

How Zenrows handles it

Markdown output keeps headings, tables and links

How to scrape the web for LLMs

  1. Pick the output per job: Markdown for a model to read, Extract for named fields.
  2. Fetch the page with Markdown output and Adaptive Stealth Mode, which escalates only when needed.
  3. Chunk and keep the source: split on headings, store URL and fetch time per chunk for citations.
  4. Give agents the same tool through the MCP server, or the CLI from a terminal or coding agent.
# pip install requests
import re
from datetime import datetime, timezone
import requests

TARGET_URL = "https://docs.example.com/api/rate-limits"  # any page you want to index

def fetch_markdown(url):
    params = {
        "apikey": "YOUR_ZENROWS_API_KEY",
        "url": url,
        "mode": "auto",
        "response_type": "markdown",
    }
    r = requests.get("https://api.zenrows.com/v1/", params=params, timeout=120)
    r.raise_for_status()
    return r.text

def chunk_by_heading(url, markdown):
    fetched_at = datetime.now(timezone.utc).isoformat()
    parts = re.split(r"\n(?=#{1,3} )", markdown)
    return [{"url": url, "fetched_at": fetched_at, "text": p.strip()}
            for p in parts if p.strip()]

chunks = chunk_by_heading(TARGET_URL, fetch_markdown(TARGET_URL))
print(len(chunks), "chunks ready to embed")

What success looks like

MeasureWhat good looks likeHow to check it
Content completeness The Markdown holds what a visitor sees, tables included Weekly spot-check against the live site
Tokens per page Markdown at a fraction of the raw HTML size HTML against Markdown token counts per URL
Failed reads Blocked or empty pages retried or flagged, never embedded Log non-200s and pages under a minimum length
Index freshness Every URL re-read within your refresh window Alert on stale fetched_at per chunk
Citation accuracy Each answer's URL contains the quoted claim String-match quotes against stored chunks

LLM web scraping FAQ

  • Two things. Scraping for LLMs prepares pages as model input: Markdown to read, JSON for tools, each with a source URL. Scraping with LLMs uses a model instead of CSS selectors to pull fields. Zenrows covers both: Fetch with Markdown output, and Extract for fields without selectors.

  • GET https://api.zenrows.com/v1/ with your apikey, the url and Markdown output on. The body is the page as Markdown, headings, lists, tables and links kept. With Adaptive Stealth Mode, Zenrows renders or applies stealth only when needed. In a terminal: zenrows fetch URL --output markdown.

  • Grounding gives the model source text at answer time, so it quotes facts instead of recalling them. The web is usually the freshest source: current pricing, today's news, the latest regulation. Fetch the pages the answer needs, pass the Markdown in, and ask for a URL per claim.

  • Connect the Zenrows MCP server once. Claude, Cursor, Codex, Windsurf, Gemini CLI and other MCP clients then see scrape and extract and call them when a task needs a page. The remote server is https://mcp.zenrows.com/mcp, with your API key as a Bearer token; Claude can also use OAuth sign-in.

  • Markdown when the model reads and reasons: articles, docs, policies, long descriptions. JSON when code consumes it: prices, ratings, dates, addresses. Many pipelines do both: Markdown to the vector store, Extract fields to a database.

  • Yes. Fetch is plain HTTP, callable from a tool function like the Node.js example. The Zenrows docs have guides for LangChain, LlamaIndex, CrewAI, Mastra, the OpenAI Agents SDK and the Claude Agent SDK, and any MCP framework can use the remote server.

  • Store fetch time per chunk and re-read URLs as fast as each source changes: news daily, docs weekly, policies monthly. Run one Batch job, hash each page's Markdown, re-embed only changed hashes. Flag pages that come back empty or much shorter instead of overwriting old chunks.

Turn the live web into usable data.