Dev.to AI πŸ€– Ai πŸ‘ 0 πŸ“– 2 min read

Why I Ditched Headless Browsers for Docs-to-RAG Ingestion (10 Pages in 4s, $0.001 Compute)

If you have ever built a production RAG pipeline over external developer docs, you probably hit the same three walls I did: Headless browser tax: Spinning up Playwright/Chromium just to fetch static Docusaurus, Mintli

If you have ever built a production RAG pipeline over external developer docs, you probably hit the same three walls I did:

  1. Headless browser tax: Spinning up Playwright/Chromium just to fetch static Docusaurus, Mintlify, or MkDocs documentation takes 45–90 seconds for 10 pages and burns gigabytes of RAM.
  2. Broken Markdown chunking: Naive ^# regex splitters mistake # this is a python comment inside fenced code blocks for H1 headingsβ€”splitting code snippets mid-function and dropping language tags (`python).
  3. Wasted re-embedding spend: Running a weekly cron job re-scrapes and re-embeds all 500 pages even when only 3 changed.

Here is the deterministic, zero-browser architecture I built to fix all threeβ€”plus two companion tools for GEO (Generative Engine Optimization) audits and scheduled webpage/pricing diff monitoring.

1. The Docs-to-RAG Discovery Waterfall (llms.txt First)

Before touching HTML crawling, check lightweight machine-readable indexes in order:

  1. /llms-full.txt: Many modern doc sites publish their entire documentation as clean Markdown in one HTTP response.
  2. /llms.txt: Curated Markdown index of doc links.
  3. /sitemap.xml / sitemap_index.xml (plus robots.txt Sitemap: directives).
  4. Prefix-locked link crawl: Only as a fallback, staying strictly inside the target docs path prefix.

2. Framework-Aware DOM Pruning + Code-Safe Chunking

Instead of converting the whole <body> and cleaning up navigation crumbs afterward, target the framework's primary article container first:

  • Docusaurus (.theme-doc-markdown)
  • MkDocs Material (.md-content__inner)
  • Mintlify (#content-area)
  • VitePress (.vp-doc), GitBook, Nextra, Starlight, Sphinx, ReadMe, Zendesk, Intercom

Two subtle engineering bugs worth watching out for:

  • Pygments <span> code blocks: Calling el.get_text("\n") inserts a newline between every highlighted token (import \n httpx). Convert <br> tags explicitly and call .get_text() without separators on the inner <code> element.
  • Heading breadcrumbs: Prepending Document: Page Title > H2 > H3 to every chunk dramatically improves vector recall when chunks lack standalone context.

Benchmark on a 512 MB container (python-httpx.org, 10 pages):

  • Duration: 4 seconds
  • Output: 179 tiktoken-bounded chunks
  • Underlying compute: ~$0.001

If you want to try it without maintaining your own scrapers (also works as an Apify MCP server for Claude/Cursor):

3. Two Companion Tools for AI Search & Monitoring

  • GEO & AI Search Readiness Auditor ($0.004/domain): Scores any website 0–100 across robots.txt AI crawler permissions (GPTBot, ClaudeBot, PerplexityBot, OAI-SearchBot), llms.txt, JSON-LD schemas, SSR extractability, and sitemaps.
  • Webpage, Pricing & Policy Diff Monitor ($0.002/check): Persists cleaned snapshots automatically across scheduled runs, strips dynamic footer noise, extracts added/removed currency prices, and triggers Slack/Discord/n8n webhooks.

Full Python examples & MCP config: weiyi-ai on Apify Β· Personal Site Β· X (@weiyi_ai).

GitHub Starter Kit (Python & MCP examples): https://github.com/onlywanggg/weiyi-ai-apify-starter

πŸ“° Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.