Prerequisites
- Python 3.10 or higher
- PraisonAI Agents package installed
crawl4aipackage installed and set up
Quick Start
1
Install
2
Crawl a page
3
Use with agent
Installation
Setup
Built-in Crawl4AI Tool
PraisonAI provides built-incrawl4ai functions that you can use directly:
URL Safety
Every URL passed tocrawl, crawl_many, extract_css, or extract_llm is validated by is_safe_http_url before any network request is made.
Blocked categories:
- Loopback (
127.0.0.0/8,::1) - Link-local (
169.254.0.0/16,fe80::/10) — includes cloud metadata IPs - Private ranges (
10.0.0.0/8,172.16.0.0/12,192.168.0.0/16) - IANA-reserved and unspecified addresses
success: False payload and log Crawl4AI <method> blocked unsafe URL: <url>:
raw:// is exempt — it needs no network access:
crawl_many preserves input order: a blocked URL appears as its blocked payload in the same index slot as the original request, never stripped or reordered.
The mentions handler (
praisonaiagents.tools.mentions) validates every redirect hop, not just the first. A message URL that redirects to an unsafe target returns [Blocked: redirect target is not allowed: <final url>]. See Spider Tools — URL Validation.Available Functions
Basic Usage
Simple Crawl
Crawl with Options
Crawl Multiple URLs
Extract with CSS Selectors
Extract with LLM
Using Crawl4AITools Class
For more control, use theCrawl4AITools class directly:
Synchronous Usage
For non-async code, use the sync versions:Schema Reference
CSS Extraction Schema
Field Types
JavaScript Execution
Execute JavaScript before crawling:Wait Conditions
Video Tutorial
Key Points
- Async by default: Use
awaitfor all crawl functions - JavaScript rendering: Full browser support for dynamic content
- CSS extraction: Fast, no-LLM structured data extraction
- LLM extraction: AI-powered extraction for complex content
- Multi-URL: Efficient concurrent crawling
Best Practices
Use CSS extraction for structured pages
Use CSS extraction for structured pages
CSS selectors are faster and more reliable than LLM extraction for well-structured pages.
Add wait conditions for dynamic pages
Add wait conditions for dynamic pages
Use
wait_for='css:.loaded' for pages that load content via JavaScript to avoid missing data.Use crawl4ai_many for multiple URLs
Use crawl4ai_many for multiple URLs
crawl4ai_many crawls concurrently and is much faster than sequential calls for multiple URLs.Use sync versions in simple scripts
Use sync versions in simple scripts
Prefer
crawl4ai_sync for non-async scripts to avoid managing the event loop manually.Related
Custom Tools
Build your own agent tools
Tools Overview
Browse PraisonAI tool documentation

