Archive websites locally with Crawl4AI (LLM-friendly crawler). Each crawl lands under sites/<hostname>/ as markdown, HTML, and JSON.
Upstream docs: docs.crawl4ai.com · Package: crawl4ai on PyPI (this project uses 0.9.2).
├── sample_crawl.py # tracked sample: deep crawl → sites/<host>/
├── crawl_* # gitignored site-specific scripts (e.g. crawl_repairsnap_*.py)
├── sites/ # gitignored — downloaded archives
│ └── example.com/ # one folder per hostname
│ ├── index.md
│ ├── index.html
│ ├── index.json
│ └── _manifest.json
├── .venv/ # gitignored
├── .gitignore
└── README.mdCrawl a site:
python sample_crawl.py https://example.com
# → sites/example.com/- Python 3.10+
- Network access (package + Playwright browsers)
- Optional:
sudoforplaywright install --with-deps
cd /path/to/this/repo
# with uv (recommended if available)
uv venv .venv
source .venv/bin/activate
# or with stdlib venv
python3 -m venv .venv
source .venv/bin/activate# with uv (works when system pip is PEP 668 managed)
uv pip install -U crawl4ai --python .venv/bin/python
# or with pip inside the venv
python -m pip install -U crawl4aiPre-release:
pip install crawl4ai --precrawl4ai-setup
crawl4ai-doctorIf Playwright browsers are missing or crawl4ai-setup fails on sudo deps:
python -m playwright install chromium
# optional (needs sudo):
python -m playwright install --with-deps chromium
# undetected-mode browsers (used by some Crawl4AI features)
python -m patchright install chromiumHealth check should crawl https://crawl4ai.com and report success.
import asyncio
from crawl4ai import AsyncWebCrawler
async def main():
async with AsyncWebCrawler() as crawler:
result = await crawler.arun(url="https://www.example.com")
print(result.markdown)
if __name__ == "__main__":
asyncio.run(main())import asyncio
from crawl4ai import AsyncWebCrawler, CrawlerRunConfig, CacheMode
from crawl4ai.content_scraping_strategy import LXMLWebScrapingStrategy
from crawl4ai.deep_crawling import BFSDeepCrawlStrategy
from crawl4ai.markdown_generation_strategy import DefaultMarkdownGenerator
async def main():
config = CrawlerRunConfig(
deep_crawl_strategy=BFSDeepCrawlStrategy(
max_depth=5,
include_external=False,
max_pages=400,
),
scraping_strategy=LXMLWebScrapingStrategy(),
markdown_generator=DefaultMarkdownGenerator(),
cache_mode=CacheMode.BYPASS,
stream=True,
verbose=True,
)
async with AsyncWebCrawler() as crawler:
async for result in await crawler.arun("https://example.com", config=config):
if result.success:
print(result.url, len(result.markdown.raw_markdown or ""))
asyncio.run(main())source .venv/bin/activate
# Basic crawl → markdown
crwl https://www.nbcnews.com/business -o markdown
# Deep crawl (BFS), max pages
crwl https://docs.crawl4ai.com --deep-crawl bfs --max-pages 10
# LLM extraction (needs provider/API key; not used by project scripts)
crwl https://www.example.com/products -q "Extract all product prices"| Command | Purpose |
|---|---|
crawl4ai-setup |
Install/configure Playwright browsers and local DB |
crawl4ai-doctor |
Verify install with a live crawl |
crwl <url> ... |
CLI crawler |
python -m playwright install chromium |
Install Chromium for Playwright |
python -m patchright install chromium |
Install Chromium for Patchright |
Activate the venv first:
source .venv/bin/activateGeneric starter script (no site-specific logic). Deep-crawls a start URL (BFS, LXML + default markdown, no LLM) into sites/<hostname>/.
python sample_crawl.py https://example.com
python sample_crawl.py https://docs.crawl4ai.com --max-pages 50 --max-depth 2
python sample_crawl.py https://example.com --site my-archive| Flag | Meaning |
|---|---|
url |
Start URL (default https://example.com/) |
--site NAME |
Folder name under sites/ (default: hostname) |
--max-pages N |
Cap pages (default 100) |
--max-depth N |
BFS depth (default 3) |
Writes path-mirrored .md / .html / .json plus sites/<host>/_manifest.json.
Copy or adapt it for a specific site (e.g. crawl_mysite.py). Files named crawl_* in the project root are gitignored so site-specific scripts stay local.
Inside each sites/<host>/ folder:
.md— markdown (result.markdown.raw_markdown).html— raw HTML.json— metadata (url, status, title, links, media, file paths)_manifest.json— crawl summary
sites/ is gitignored so archives stay local and do not bloat the repo.
See .gitignore. Notable entries:
| Path | Why |
|---|---|
sites/ |
Downloaded site archives |
site/ |
Legacy output folder name |
/crawl_* |
Site-specific crawl scripts in the project root |
.venv/ |
Local virtualenv |
__pycache__/ |
Python bytecode |
.env |
Secrets |
.crawl4ai/, Playwright caches |
Local crawler/browser data if created in-repo |
docker pull unclecode/crawl4ai:latest
docker run -d -p 11235:11235 --name crawl4ai --shm-size=1g unclecode/crawl4ai:latestDashboard: http://localhost:11235/dashboard · Playground: http://localhost:11235/playground
- Prefer the project
.venv; do not install into the system Python on PEP 668 distros without a venv. - Playwright browser binaries may live under a sandbox cache path; if launch fails with “Executable doesn't exist”, re-run
python -m playwright install chromium. - Attribution: this project uses Crawl4AI (https://github.com/unclecode/crawl4ai) for web data extraction. Licensed Apache-2.0 upstream.