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:
- 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.
-
Broken Markdown chunking: Naive
^#regex splitters mistake# this is a python commentinside fenced code blocks for H1 headingsβsplitting code snippets mid-function and dropping language tags (`python). - 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:
-
/llms-full.txt: Many modern doc sites publish their entire documentation as clean Markdown in one HTTP response. -
/llms.txt: Curated Markdown index of doc links. -
/sitemap.xml/sitemap_index.xml(plusrobots.txtSitemap:directives). - 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: Callingel.get_text("\n")inserts a newline between every highlighted token (import\nhttpx). Convert<br>tags explicitly and call.get_text()without separators on the inner<code>element. -
Heading breadcrumbs: Prepending
Document: Page Title > H2 > H3to 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):
-
Docs to RAG Chunks (
$0.002/page,$0on unchanged pages viapreviousPageHashes).
3. Two Companion Tools for AI Search & Monitoring
-
GEO & AI Search Readiness Auditor (
$0.004/domain): Scores any website 0β100 acrossrobots.txtAI 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
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.