How to Scrape a Site to Markdown With Crawl4AI
Crawl4AI is an open-source Python crawler that converts pages into Markdown optimized for language models, handling JavaScript rendering through a headless browser. You install the package, run a short script, and get clean text without the ad blocks and navigation chrome.
It is the sensible starting point when a RAG pipeline needs a site’s content and an API-based crawler is too expensive per page.
What does a first crawl look like
A minimal run specifies a URL, a browser configuration, and a Markdown generator, then iterates results. Concurrency is set explicitly; the default is conservative for good reason.
Render JavaScript only where needed. Static pages crawl several times faster with the browser disabled, and most documentation sites are static.
Why do some pages come back empty
Three causes:
- Content loads client-side after a delay. Enable browser rendering and add a wait for a selector rather than a fixed sleep.
- The site serves a consent or age gate that intercepts the page. Add a cookie or accept step, or exclude the domain.
- A bot wall returns a challenge page with a 200 status. The Markdown will be short and generic, which is your signal.
A 200 with 200 words when the page should have 3,000 is the shape of every bot wall. Log word counts per page and alert on outliers.
| Symptom | Likely cause |
|---|---|
| Empty Markdown | Content rendered after load |
| Short, generic text | Bot challenge page |
| Garbled order | Multi-column layout |
| Missing tables | Table extraction disabled |
| Slow crawl | Browser rendering on static pages |
What politeness settings matter
Rate limits per domain, a user agent that identifies you, and a robots.txt check where the tool supports it. Crawling 5,000 pages at full concurrency from one IP is how a project gets banned in an hour.
Set concurrency to one or two per domain for the first run. Confirm the site tolerates it, then increase. Ban risks are about burst, not totals.
How do you feed the output into a pipeline
Chunk the Markdown by heading, keep the source URL and heading path as metadata on each chunk, and store both. Chunk without metadata and you cannot cite the source when the answer is wrong.
For a docs corpus, one chunk per H2 section works well. For a long article, split by paragraph groups with overlap.
When is a hosted crawler better
Sites with aggressive bot protection, where maintaining a headless browser setup becomes a job. A managed scraping service handles that. Also when the workflow needs extraction into a spreadsheet rather than Markdown; a tool like Browse AI is built for that shape.
Who should not run it
Anyone without Python experience, teams that need guaranteed legal review of every crawled source, and projects where a single page fails the crawl and blocks the entire pipeline. Add a per-page timeout and continue on failure before you crawl at scale.
Quick Summary
- Crawl4AI is an open-source Python crawler that outputs LLM-friendly Markdown.
- Enable browser rendering only for pages that need it.
- Short Markdown with a 200 status usually means a bot wall.
- Crawl one or two pages per domain first; bursts get IPs banned.
- Keep source URL and heading path as chunk metadata or citation fails.
