By Rajesh Kannan, Co-Founder & CTO, Gramosoft · Last updated: · Every script below was run with Crawl4AI 0.9.6 on December 1, 2026

Crawl4AI is an open-source Python crawler that turns web pages into clean Markdown or JSON for LLMs and RAG. This tutorial runs every step on a local test shop and shows what actually came back, including two settings that quietly lost data. It starts with the GcrawlAI route, for when you'd rather not run browsers at all, then builds the same crawl with Crawl4AI.

TL;DR

  • Install: pip install -U crawl4ai, then crawl4ai-setup for the browser. Version 0.9.6 needs Python 3.10 or newer.
  • Wait for the value, not the element: on our test pages, wait_for="css:.price" returned 0 of 6 prices because the element said "Loading…". A JavaScript condition on the price text returned 6 of 6.
  • Strip the noise yourself: excluded_tags and excluded_selector removed the cookie banner; the pruning filter alone didn't. The docs' example pruning values dropped our product title and price.
  • Use arun_many: 24 pages took 4.3 s against 14.0 s in a loop, and a filtered deep crawl fetched exactly the 29 pages we wanted.
  • Skip the browsers entirely with GcrawlAI: rendering, residential IPs and anti-bot handling in one request, and failed requests are never charged.

How do you use Crawl4AI in Python? Install it with pip install -U crawl4ai and run crawl4ai-setup. Open an AsyncWebCrawler, call arun(url, config=CrawlerRunConfig(...)), and read result.markdown. Add JsonCssExtractionStrategy for structured JSON, LLMExtractionStrategy for fields that need a model, and BFSDeepCrawlStrategy to crawl a whole site with depth and page limits.

Option Who runs the browsers Anti-bot and proxies Cost Best for
GcrawlAI GcrawlAI, or you on the MIT core Included in every request 50 free requests a month, then $0.67 to $9.67 per 1,000 Protected sites, no browser fleet
Crawl4AI library You, in your Python process Your settings and proxies Free (Apache 2.0); you pay for servers, proxies and LLM calls Full control, custom pipelines
Crawl4AI in Docker You, on your own server Your settings and proxies Free; you pay for hosting A shared crawl service for a team
Crawl4AI Cloud Crawl4AI Handled by Crawl4AI 1,000 free credits a month, plans from $10 Crawl4AI's API without hosting it

Crawl a site without running a browser: GcrawlAI

Crawl4AI gives you a crawler; you still run the browsers, proxies and retries behind it. GcrawlAI runs them for you. Each page loads in a real browser through a residential IP in the country you choose, with stealth escalation when a bot check appears, and comes back as Markdown, HTML or JSON. Failed pages are never charged.

GcrawlAI homepage with the logo and menu (Products, Playground, Extractors, Docs, Pricing, Blog, Use Cases, Custom Request): Transform any website into structured LLM-ready data, the open-source web scraping API for AI agents, RAG pipelines and data teams, with JavaScript rendering, anti-bot stealth and proxies included in every request and no credit system; tabs for Scrape, Map, Crawl, Batch, Screenshot, Search and Smart Answer
The GcrawlAI homepage: crawl a site without running Crawl4AI's browsers yourself (screenshot taken October 26, 2026).

The script below crawls the same kind of shop as our Crawl4AI examples, up to 40 pages, and keeps the category and product pages as JSON lines. There's nothing to install beyond the SDK. Point base_url at your own server to run it on the self-hosted core.

# gcrawlai_crawl.py
# pip install gcrawl-sdk
"""The same site crawl through GcrawlAI: no browser to install, every page rendered in a real browser through
a residential IP, one request per page, and failed pages are never charged."""
import json
import os

from gcrawl_sdk import CrawlOptions, GcrawlClient

gc = GcrawlClient(api_key=os.getenv("GCRAWL_API_KEY", "gc-YOUR_API_KEY"))
# Self-hosted core: GcrawlClient(api_key=..., base_url="http://localhost:8000")

job = gc.crawl(
    "https://shop.example.com/",
    options=CrawlOptions(max_pages=40, same_domain_only=True, markdown_enabled=True, proxy_geo="US"),
    wait=True,
)
if not job.is_completed:
    raise SystemExit(f"crawl ended with status {job.status}")

with open("site.jsonl", "w", encoding="utf-8") as out:
    for page in job.pages:
        if "/product/" in page.url or "/category/" in page.url:  # path filter, applied to the results
            out.write(json.dumps({"url": page.url, "markdown": page.markdown}) + "\n")
print(f"{len(job.pages)} pages crawled, {job.pages_failed or 0} failed (not charged)")
Stitched sampler diagram of one GcrawlAI crawl: start URL, discover links from the sitemap and pages, render each page in a real browser through a residential IP, escalate stealth when a bot check appears, return Markdown, HTML or JSON per page; one request per page, failed pages free
What a GcrawlAI crawl does for each page, with no browser to install.
  • One request covers everything: JavaScript rendering, rotating residential proxies, handling for Cloudflare, DataDome, Akamai and PerimeterX, and CAPTCHA solving, with no credit multipliers.
  • Scrape, crawl and map: one page, a whole site, or just its URLs, plus screenshots and the Search API on the same key.
  • How you connect: the managed Cloud API, the Python SDK, an MCP server for AI agents, the Playground and docs, or the MIT-licensed core on your servers.
  • Billing: 50 free requests a month with no card, then $0.67 to $9.67 per 1,000 requests; blocked pages, CAPTCHAs, timeouts and server errors are never billed.

Where it falls short: the crawl API has no depth or URL-pattern filters yet, so you filter the results, as the script does; Crawl4AI's deep-crawl filters and scorers are richer. There's no plain-English extraction prompt; structured data comes from extractors, Markdown or your own selectors. Crawl4AI Cloud's free tier of 1,000 credits a month may go further than our 50 requests, depending on how many credits a page costs, and the Crawl4AI library itself costs nothing.

"Crawl4AI is a good library, and the code is the easy part. The work is everything around it: browsers that leak memory, proxies that get flagged, and pages that come back looking fine but empty."

Rajesh Kannan, Co-Founder & CTO at Gramosoft

What Crawl4AI is, and when to use it

Crawl4AI is an open-source Python library from unclecode on GitHub, licensed Apache 2.0. It drives a Playwright browser, renders the page, cleans it into Markdown, and can extract JSON with CSS, XPath or an LLM. Use it when you want crawling and extraction inside your own Python code.

Piece What it does Where you set it
BrowserConfig Headless mode, user agent, proxy, viewport, persistent profile Once, when you open AsyncWebCrawler
CrawlerRunConfig Waits, cache, what to strip, Markdown filter, extraction, deep crawl Per arun or arun_many call
Fit Markdown A filtered copy of the page's Markdown (pruning or BM25) DefaultMarkdownGenerator(content_filter=...)
Extraction strategies CSS, XPath, regex or LLM to JSON extraction_strategy=
Deep crawling BFS, DFS or best-first, with depth, page and URL filters deep_crawl_strategy=

It's a poor fit for static pages you could fetch with plain HTTP, since every page goes through a full browser. Our comparison of Scrapy, Crawlee and Scrapling covers the lighter options.

Install Crawl4AI

Crawl4AI installs from PyPI, but the browser doesn't come with it. Run pip install -U crawl4ai in a fresh virtual environment, then crawl4ai-setup to download Chromium, and crawl4ai-doctor to check the install. Version 0.9.6, released November 20, 2026, needs Python 3.10 or newer and Playwright 1.64.1 or newer.

  • Pin the version in production, for example crawl4ai==0.9.6. Recent releases fixed security issues, so read the release notes before upgrading rather than never upgrading.
  • The browser download can fail on locked-down servers. Ours couldn't reach Playwright's download site, so we pointed it at an installed Chromium. Docker images and CI runners hit the same wall.
  • A Cloud banner prints on every run; set CRAWL4AI_NO_CLOUD_NOTICE=1 to hide it.
  • Attribution: the README asks you to credit Crawl4AI with a badge or one line of text in your documentation.

Your first crawl: one page to clean Markdown

The basic call is short: open an AsyncWebCrawler, call arun, read result.markdown. The useful work is in CrawlerRunConfig: what to wait for, what to strip, and how to filter what's left. The script below does all three on a product page whose price loads with JavaScript.

# first_crawl.py
# pip install -U crawl4ai && crawl4ai-setup
"""Crawl one page and compare the full Markdown with the filtered "fit" Markdown."""
import asyncio
import sys

from crawl4ai import AsyncWebCrawler, BrowserConfig, CacheMode, CrawlerRunConfig, DefaultMarkdownGenerator
from crawl4ai.content_filter_strategy import PruningContentFilterLXML  # PruningContentFilter is deprecated

URL = sys.argv[1] if len(sys.argv) > 1 else "http://127.0.0.1:8940/product/laptops-3"


async def main():
    browser = BrowserConfig(headless=True)
    run = CrawlerRunConfig(
        cache_mode=CacheMode.BYPASS,          # always fetch fresh while you're testing
        # wait for the JavaScript price itself: "css:.price" passes while it still says "Loading…"
        wait_for="js:() => document.querySelector('.price')?.textContent.startsWith('$')",
        excluded_tags=["nav", "footer", "aside"],   # drop site chrome before the Markdown is built
        excluded_selector=".cookie, .related",
        # Defaults on purpose: the docs' example (threshold=0.45, min_word_threshold=5) pruned our title and price,
        # because short lines fall under the word threshold.
        markdown_generator=DefaultMarkdownGenerator(content_filter=PruningContentFilterLXML()),
    )
    async with AsyncWebCrawler(config=browser) as crawler:
        result = await crawler.arun(url=URL, config=run)
    if not result.success:
        raise SystemExit(f"failed: {result.status_code} {result.error_message}")
    raw, fit = result.markdown.raw_markdown, result.markdown.fit_markdown
    print(f"status {result.status_code} | raw {len(raw.split())} words | fit {len(fit.split())} words")
    print(fit[:300])


asyncio.run(main())
# first_crawl_output.txt (printed output)
status 200 | raw 177 words | fit 177 words
# Laptop Model 3
$237
Rating 4.7 / 5.
## Review
Choosing hardware for a small team is mostly about trade-offs between weight, battery life and repairability. We tested each model for a week of normal office work, noting heat, noise and how easy the parts were to replace. Choosing hardware for a smal

Three settings carry the weight. wait_for waits until the price text starts with a dollar sign, because a selector like css:.price matches the moment the "Loading…" placeholder appears. excluded_tags and excluded_selector remove the menu, footer, sidebar and cookie banner before the Markdown is built. PruningContentFilterLXML replaces PruningContentFilter, which the docs now mark as deprecated.

Extract structured data with CSS selectors

When the page has a repeating layout, like product cards, CSS selectors give you JSON with no LLM, no token cost and the same output every run. JsonCssExtractionStrategy takes a schema: a base selector for each item, and the fields inside it. Here it pulls name, link, price and rating from a category page.

# css_extract.py
# pip install -U crawl4ai && crawl4ai-setup
"""Pull structured JSON from a listing page with CSS selectors: no LLM, no tokens, same output every run."""
import asyncio
import json
import sys

from crawl4ai import AsyncWebCrawler, CacheMode, CrawlerRunConfig, JsonCssExtractionStrategy

URL = sys.argv[1] if len(sys.argv) > 1 else "http://127.0.0.1:8940/category/laptops"

SCHEMA = {
    "name": "products",
    "baseSelector": "div.product",
    "fields": [
        {"name": "name", "selector": "h2 a", "type": "text"},
        {"name": "url", "selector": "h2 a", "type": "attribute", "attribute": "href"},
        {"name": "price", "selector": ".price", "type": "text"},
        {"name": "rating", "selector": ".rating", "type": "text"},
    ],
}


async def main():
    run = CrawlerRunConfig(
        cache_mode=CacheMode.BYPASS,
        wait_for="js:() => [...document.querySelectorAll('.price')].every(e => e.textContent.startsWith('$'))",
        extraction_strategy=JsonCssExtractionStrategy(SCHEMA),
    )
    async with AsyncWebCrawler() as crawler:
        result = await crawler.arun(url=URL, config=run)
    items = json.loads(result.extracted_content or "[]")
    print(f"{len(items)} products")
    print(json.dumps(items[:2], indent=2))


asyncio.run(main())
# css_extract_output.txt (printed output)
6 products
  {
    "name": "Laptop Model 1",
    "url": "/product/laptops-1",
    "price": "$163",
    "rating": "4.0 / 5"
  },
  {
    "name": "Laptop Model 2",
    "url": "/product/laptops-2",
    "price": "$200",
    "rating": "4.3 / 5"
  }
]

The JavaScript wait matters here too: without it, all six prices came back as "Loading…". For prices and other numbers, prefer CSS extraction over parsing Markdown; on our category pages the Markdown joined each price and rating into one string, "$1964.0 / 5".

When the fields need an LLM

Use LLMExtractionStrategy when a field needs reading rather than selecting, like a one-line verdict or a list of cons from a review. It works with hosted models or a local Ollama model. Send fit_markdown instead of raw HTML, because every page, and every chunk of a long page, is a paid model call.

# llm_extract.py
# pip install -U crawl4ai && crawl4ai-setup
"""Extract fields that need interpretation with an LLM. Use it after CSS selectors stop being enough:
every page (and every chunk of a long page) is a model call you pay for. Not part of our timed test."""
import asyncio
import json
import os

from pydantic import BaseModel

from crawl4ai import AsyncWebCrawler, CacheMode, CrawlerRunConfig, LLMConfig, LLMExtractionStrategy


class Review(BaseModel):
    product: str
    price_usd: float
    verdict: str          # one sentence, written by the model
    cons: list[str]


strategy = LLMExtractionStrategy(
    llm_config=LLMConfig(provider="openai/gpt-4o-mini", api_token=os.getenv("OPENAI_API_KEY")),
    # local model instead: LLMConfig(provider="ollama/llama3.2", base_url="http://localhost:11434")
    schema=Review.model_json_schema(),
    extraction_type="schema",
    instruction="Extract the product, its price in USD, a one-sentence verdict and the cons mentioned in the review.",
    input_format="fit_markdown",          # send the filtered page, not the menus and footer
    chunk_token_threshold=1200, apply_chunking=True,
    extra_args={"temperature": 0},
)


async def main():
    run = CrawlerRunConfig(cache_mode=CacheMode.BYPASS, extraction_strategy=strategy,
                           excluded_tags=["nav", "footer", "aside"])
    async with AsyncWebCrawler() as crawler:
        result = await crawler.arun(url="https://shop.example.com/product/laptop-3", config=run)
    print(json.dumps(json.loads(result.extracted_content), indent=2))
    strategy.show_usage()                  # tokens used, so you can price the full crawl


asyncio.run(main())

We didn't run this one in our test, because it needs a model key. Call show_usage() on a sample of pages first, then multiply by your page count before you crawl thousands.

Crawl a whole site with deep crawling

To follow links instead of listing URLs, pass a deep-crawl strategy. BFSDeepCrawlStrategy goes level by level; DFSDeepCrawlStrategy follows one branch first; BestFirstCrawlingStrategy visits the highest-scoring links first. Always set max_depth, max_pages and a URL filter, or the crawl will wander into every footer link.

# deep_crawl.py
# pip install -U crawl4ai && crawl4ai-setup
"""Crawl a site breadth-first with depth, page and URL limits, and write one JSON line per page."""
import asyncio
import json
import sys

from crawl4ai import (AsyncWebCrawler, BFSDeepCrawlStrategy, CacheMode, CrawlerRunConfig, DefaultMarkdownGenerator,
                      FilterChain, URLPatternFilter)
from crawl4ai.content_filter_strategy import PruningContentFilterLXML

START = sys.argv[1] if len(sys.argv) > 1 else "http://127.0.0.1:8940/"


async def main():
    strategy = BFSDeepCrawlStrategy(
        max_depth=2,                     # home = 0, categories = 1, products = 2
        max_pages=40,                    # hard stop, whatever the site links to
        include_external=False,
        filter_chain=FilterChain([URLPatternFilter(patterns=["*/category/*", "*/product/*"])]),
    )
    run = CrawlerRunConfig(
        deep_crawl_strategy=strategy,
        cache_mode=CacheMode.BYPASS,
        check_robots_txt=True,
        # prices load with JavaScript; pages without a .price pass at once
        wait_for="js:() => [...document.querySelectorAll('.price')].every(e => e.textContent.startsWith('$'))",
        stream=True,                     # handle pages as they finish instead of waiting for all
        excluded_tags=["nav", "footer", "aside"],
        excluded_selector=".cookie, .related",
        markdown_generator=DefaultMarkdownGenerator(content_filter=PruningContentFilterLXML()),
    )
    ok = failed = 0
    async with AsyncWebCrawler() as crawler:
        with open("site.jsonl", "w", encoding="utf-8") as out:
            async for page in await crawler.arun(url=START, config=run):
                if not page.success:
                    failed += 1
                    continue
                ok += 1
                out.write(json.dumps({"url": page.url, "depth": page.metadata.get("depth"),
                                      "markdown": page.markdown.fit_markdown}) + "\n")
    print(f"{ok} pages saved, {failed} failed")


asyncio.run(main())
# deep_crawl_output.txt (printed output)
29 pages saved, 0 failed

From the home page, the filter kept the crawl to the 4 category pages and 24 product pages, 29 in all, and skipped the blog, cart and footer pages. With stream=True, each page is written as it finishes, so a crash halfway doesn't lose the first half. For a list of URLs you already have, arun_many runs them concurrently. Our guide to crawling an entire website covers sitemap-first discovery.

What we measured on a test site

We built a local shop, three levels deep, with prices that load by JavaScript and the usual menus, footer, sidebar and cookie banner. Then we checked the claims tutorials make: whether the prices come through, what each Markdown setting keeps, and how much faster concurrent crawling is. Everything ran on a 2-vCPU Linux server.

Stitched sampler of test results: prices captured, requests plus BeautifulSoup 0 of 6, Crawl4AI without wait 0 of 6, wait_for css price 0 of 6, wait_for price text 6 of 6; Markdown words, raw default 250 with cookie text, raw with excluded tags 177, fit with pruning only 204 with cookie text, excluded plus pruning 177, docs example pruning values 152 with title and price dropped
What came back from our test shop: prices by wait setting, and Markdown by filter setting (December 1, 2026).
# lab_output.txt (printed output)
1. Prices on /category/laptops (6 products)
   requests + BeautifulSoup        0/6
   Crawl4AI, no wait_for            0/6
   Crawl4AI, wait_for="css:.price"  0/6
   Crawl4AI, wait_for price text    6/6

2. Markdown for /product/laptops-3 (words, keeps title, keeps price)
   raw_markdown, defaults              250 words  title yes  price yes  cookie text yes
   raw_markdown, excluded tags         177 words  title yes  price yes  cookie text no
   fit_markdown, pruning only          204 words  title yes  price yes  cookie text yes
   fit_markdown, excluded + pruning    177 words  title yes  price yes  cookie text no
   fit_markdown, docs example values   152 words  title NO   price NO   cookie text no

3. Deep crawl from / (BFS, max_depth=2, max_pages=40, category/product filter)
   29 pages in 5.0 s, by depth {0: 1, 1: 4, 2: 24}, blog/footer pages crawled: 0

4. 24 product pages
   sequential arun loop   14.0 s
   arun_many               4.3 s  (24/24 succeeded)

The surprises were both about losing data quietly. A CSS wait passed before the data arrived, so the crawl "succeeded" with no prices. And the pruning values from the docs' own example, threshold=0.45 with min_word_threshold=5, dropped the product title and price, because they're shorter than five words. The default filter kept them. Check a sample of output before you trust a filter.

Embroidered bar chart: 24 product pages took 14.0 seconds in a sequential arun loop and 4.3 seconds with arun_many; a filtered BFS deep crawl fetched 29 pages in 5.0 seconds
Crawl time on a 2-vCPU Linux server, Crawl4AI 0.9.6 (December 1, 2026).

Concurrency is where Crawl4AI earns its keep: arun_many fetched 24 pages about three times faster than a loop, with all 24 succeeding. On real sites the gap depends on the server and your memory; the MemoryAdaptiveDispatcher lowers concurrency when RAM runs short.

Where Crawl4AI falls short

Crawl4AI handles rendering and cleanup well, but it doesn't make you unblockable, and every page costs a browser. Its undetected-browser docs say plainly that advanced anti-bot services can still block it. Plan for proxies, memory and model costs from the start.

  • Bot protection: stealth and the undetected browser help, but you still need clean residential IPs and sane request rates. Our guide to scraping without getting blocked covers the rest.
  • Browser overhead: every page is a full render, so it's slower and heavier than plain HTTP for static pages.
  • LLM costs: long pages split into several chunks, and each chunk is a model call.
  • Upkeep: browser downloads, version pins and security releases are yours to manage.

Crawl4AI or a crawling API in 2027?

Pick Crawl4AI when you want full control and can run browsers and proxies yourself; the library costs nothing. Pick a crawling API when the sites fight back, or when nobody on the team wants to own a browser fleet. Many teams use both: the library for friendly sites, an API for protected ones.

Your situation Good fit Where GcrawlAI fits
Learning, prototypes, a few hundred pages Crawl4AI library 50 free requests a month to compare output
Custom crawl logic, URL scoring, sessions Crawl4AI library or Docker For the protected domains your crawler can't reach
Sites behind Cloudflare, DataDome or Akamai A managed API with residential IPs Anti-bot handling in one request, failed requests free
RAG ingestion of documentation sites Crawl4AI deep crawl, or a crawl API Crawl to Markdown without hosting browsers
AI agents that browse the live web An API with MCP MCP server, Search API and scrape on one key
No servers, no maintenance Crawl4AI Cloud or GcrawlAI Cloud API, or the MIT core if you change your mind

For a wider view, see our roundup of open-source web crawlers and our comparison of crawling APIs for RAG.

Frequently asked questions

Is Crawl4AI free?

The library is free and open source under Apache 2.0, and the README asks you to credit it with a badge or one line of text. You still pay for servers, proxies and any LLM calls. Crawl4AI Cloud, the hosted version, gives 1,000 free credits a month, and paid plans start at $10 a month.

Does Crawl4AI need an LLM or an API key?

No. Crawling, Markdown, the pruning and BM25 filters, and CSS, XPath and regex extraction all run without a model or key. You only need an LLM for LLMExtractionStrategy or the LLM content filter, and that can be a hosted model or a local one through Ollama.

Why does Crawl4AI return empty or placeholder data?

Usually because the page loaded its data with JavaScript after Crawl4AI captured it. In our test, wait_for="css:.price" passed while the price still said "Loading…", and returned 0 of 6 prices. A JavaScript condition that waits for the real value, such as text starting with a dollar sign, returned 6 of 6.

What is fit Markdown in Crawl4AI?

It's a filtered copy of the page's Markdown, produced by a content filter such as pruning or BM25, next to the full raw_markdown. Strip menus and banners with excluded_tags first. In our test, the docs' example pruning values dropped the product title and price, so check a sample before trusting a filter.

How do I crawl a whole website with Crawl4AI?

Pass BFSDeepCrawlStrategy, DFSDeepCrawlStrategy or BestFirstCrawlingStrategy as deep_crawl_strategy in CrawlerRunConfig. Set max_depth, max_pages and a URLPatternFilter. In our test that fetched exactly 29 category and product pages in 5 seconds, and skipped the blog and footer pages. Add stream=True to save each page as it finishes, so a crash halfway through doesn't lose the pages you already have.

Can Crawl4AI bypass Cloudflare and other anti-bot systems?

Sometimes. It ships stealth options and an undetected browser mode, but its own documentation says advanced anti-bot services can still block it. You'll also need residential proxies and a sensible request rate. For heavily protected sites, a managed API that handles rendering, IPs and challenges is usually less work.

Is GcrawlAI open source, and what does it cost?

Yes. The core is MIT-licensed and self-hostable, next to a managed Cloud API, Python SDK and MCP server. The free plan has 50 requests a month with no card, and paid plans cost $0.67 to $9.67 per 1,000 requests. Rendering, residential IPs and anti-bot handling come in one request, and failed requests are never charged.

RK

Rajesh Kannan M

Rajesh Kannan M is Co-Founder & CTO of Gramosoft in Chennai, where he leads the team building GcrawlAI, an open-source web scraping, crawling and Search API platform for developers and AI agents. LinkedIn

Rather not run the browsers?

Start with 50 free requests a month, no card. GcrawlAI crawls and scrapes in real browsers through residential IPs, handles bot checks, and returns Markdown, HTML or JSON, through the Cloud API, Python SDK or MCP, or self-hosted under MIT. Failed requests are never charged.

CTA Illustration