docs/examples/README_BUILTIN_BROWSER.md
This document explains the builtin browser feature in Crawl4AI and how to use it effectively.
The builtin browser is a persistent Chrome instance that Crawl4AI manages for you. It runs in the background and can be used by multiple crawling operations, eliminating the need to start and stop browsers for each crawl.
Benefits include:
Using the builtin browser in your code is simple:
from crawl4ai import AsyncWebCrawler, BrowserConfig, CrawlerRunConfig
# Create browser config with builtin mode
browser_config = BrowserConfig(
browser_mode="builtin", # This is the key setting!
headless=True # Can be headless or not
)
# Create the crawler
crawler = AsyncWebCrawler(config=browser_config)
# Use it - no need to explicitly start()
result = await crawler.arun("https://example.com")
Key points:
browser_mode="builtin" in your BrowserConfigstart() call - the crawler will automatically connect to the builtin browserclose() - the browser stays runningThe CLI provides commands to manage the builtin browser:
# Start the builtin browser
crwl browser start
# Check its status
crwl browser status
# Open a visible window to see what the browser is doing
crwl browser view --url https://example.com
# Stop it when no longer needed
crwl browser stop
# Restart with different settings
crwl browser restart --no-headless
When crawling via CLI, simply add the builtin browser mode:
crwl https://example.com -b "browser_mode=builtin"
When a crawler with browser_mode="builtin" is created:
The browser process continues running after your script exits
During installation, Crawl4AI attempts to create a builtin browser automatically
See the builtin_browser_example.py file for a complete example.
Run it with:
python builtin_browser_example.py
The builtin browser is ideal for:
You might not want to use it when:
If you encounter issues:
Check the browser status:
crwl browser status
Try restarting it:
crwl browser restart
If problems persist, stop it and let Crawl4AI start a fresh one:
crwl browser stop