Turn any website into LLM-ready Markdown with Crawl4AI
Install Crawl4AI and scrape web pages into clean Markdown you can feed to a model, a RAG pipeline, or an agent.
A Python script that fetches any page, including JavaScript-heavy ones, and returns clean Markdown ready for an LLM.
Models are only as good as what you put in their context window. Raw HTML wastes that space on menus, scripts, and cookie banners. Crawl4AI loads a page in a real browser and hands back the content as Markdown, which is the format models read best.
Install
pip install -U crawl4ai
crawl4ai-setupThe second command downloads the browser Crawl4AI drives. You run it once. If anything looks off:
crawl4ai-doctorScrape one page
import asyncio
from crawl4ai import AsyncWebCrawler
async def main():
async with AsyncWebCrawler() as crawler:
result = await crawler.arun(url="https://news.ycombinator.com")
print(result.markdown)
asyncio.run(main())Run it and you get the page as Markdown: headings, links, and text, without the page chrome.
Scrape several pages
Reuse one crawler for a batch. It keeps the browser open, which is much faster than starting it per page:
import asyncio
from crawl4ai import AsyncWebCrawler
URLS = [
"https://docs.python.org/3/tutorial/introduction.html",
"https://docs.python.org/3/tutorial/controlflow.html",
]
async def main():
async with AsyncWebCrawler() as crawler:
for url in URLS:
result = await crawler.arun(url=url)
name = url.rstrip("/").split("/")[-1].replace(".html", "") + ".md"
with open(name, "w") as f:
f.write(result.markdown)
print("saved", name)
asyncio.run(main())Hand the result to a model
The Markdown is now ordinary text. Summarize it with a local model:
import ollama
summary = ollama.chat(
model="gemma4",
messages=[{"role": "user", "content": f"Summarize the key points:\n\n{result.markdown}"}],
)
print(summary["message"]["content"])Or drop the saved .md files into an AnythingLLM workspace and ask questions across all of them.
Be a good citizen
- Check the site's terms and
robots.txtbefore crawling, and do not hammer a server: add a pause between requests on large jobs. - Scraped text is untrusted input. A page can contain instructions aimed at your model. If the output feeds an agent with tools, read about RAG poisoning first.
What to do next
Crawl4AI also runs as a Docker server with an HTTP API and has structured extraction options; the project docs cover both. For pages that need clicking and logging in, use a browser agent.
Sources
Open-source tools change quickly. Commands here were checked on Nov 14, 2026; if one fails, the project's README is the source of truth.