crawl4ai

unclecodeApache-2.0活跃维护

面向 AI 智能体的网页抓取与数据提取爬虫,把网页转成干净的 Markdown 喂给 LLM 和 RAG 流程,支持自托管。

Official Crawl4AI Cloud: a hosted web scraping, extraction, and search API for AI agents. Free API key, 1,000 credits a month, no card. Fully open source: this repo is the Apache-2.0 crawler that powers it, and you can self-host it.

v0.9.5发布于 2026-10-14 10:25 UTC87,163star +135 / 7 天9,083fork同步于 2026-11-10 05:17 UTC

怎么上手

由 README 提炼,执行前请确认
pip install -U crawl4ai
crawl4ai-setup
硬件要求按 README 说明

README 未说明显存或 GPU 要求;自托管需在本地运行 Chromium、Firefox 或 WebKit 浏览器,Docker 镜像支持 AMD64 与 ARM64。

有 Docker 镜像
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

把网页转成 LLM 可读 Markdown 的开源爬虫,可自托管也可用托管 API

面向 AI 智能体的网页抓取与数据提取爬虫,把网页转成干净的 Markdown 喂给 LLM 和 RAG 流程,支持自托管。

核心能力

  • 生成带标题表格代码块的干净 Markdown 并附引用列表
  • 用 CSS/XPath/正则或 LLM 抽取结构化 JSON
  • 支持 BFS/DFS/最优优先深度爬取并可从断点恢复
  • 异步浏览器池并发抓取多 URL,带缓存与钩子
  • Docker 自托管提供 REST API 与 MCP 接入

容易踩的坑

pip 安装后必须再跑 crawl4ai-setup 安装浏览器,否则无法抓取;Docker 服务必须设置 CRAWL4AI_API_TOKEN,否则只能在容器内访问;浏览器安装失败时需手动执行 python -m playwright install --with-deps chromium。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README
这个条目还没有人工点评。如果它对你很有用,欢迎到 提交仓库 页写下你的使用经验。

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    最近发版

    5 个版本v0.9.5
    1. v0.9.5Release v0.9.5最新正式版2026-10-14 · 2026-10-14 10:25 UTC

      🎉 Crawl4AI v0.9.5 Released!

      📦 Installation

      PyPI:

      pip install crawl4ai==0.9.5
      

      Docker:

      docker pull unclecode/crawl4ai:0.9.5
      docker pull unclecode/crawl4ai:latest
      

      Note: Docker images are being built and will be available shortly. Check the Docker Release workflow for build status.

      📝 What's Changed

      See CHANGELOG.md for details.

    2. v0.9.4Release v0.9.42026-09-23 · 2026-09-23 12:14 UTC
      查看更新说明

      🎉 Crawl4AI v0.9.4 Released!

      📦 Installation

      PyPI:

      pip install crawl4ai==0.9.4
      

      Docker:

      docker pull unclecode/crawl4ai:0.9.4
      docker pull unclecode/crawl4ai:latest
      

      Note: Docker images are being built and will be available shortly. Check the Docker Release workflow for build status.

      📝 What's Changed

      See CHANGELOG.md for details.

    3. v0.9.3Release v0.9.32026-08-31 · 2026-08-31 11:34 UTC
      查看更新说明

      🎉 Crawl4AI v0.9.3 Released!

      📦 Installation

      PyPI:

      pip install crawl4ai==0.9.3
      

      Docker:

      docker pull unclecode/crawl4ai:0.9.3
      docker pull unclecode/crawl4ai:latest
      

      Note: Docker images are being built and will be available shortly. Check the Docker Release workflow for build status.

      📝 What's Changed

      See CHANGELOG.md for details.

    4. v0.9.2Release v0.9.22026-07-15 · 2026-07-15 08:27 UTC
      查看更新说明

      🎉 Crawl4AI v0.9.2 Released!

      📦 Installation

      PyPI:

      pip install crawl4ai==0.9.2
      

      Docker:

      docker pull unclecode/crawl4ai:0.9.2
      docker pull unclecode/crawl4ai:latest
      

      Note: Docker images are being built and will be available shortly. Check the Docker Release workflow for build status.

      📝 What's Changed

      See CHANGELOG.md for details.

    5. v0.9.1Release v0.9.12026-07-08 · 2026-07-08 14:29 UTC
      查看更新说明

      🎉 Crawl4AI v0.9.1 Released!

      📦 Installation

      PyPI:

      pip install crawl4ai==0.9.1
      

      Docker:

      docker pull unclecode/crawl4ai:0.9.1
      docker pull unclecode/crawl4ai:latest
      

      Note: Docker images are being built and will be available shortly. Check the Docker Release workflow for build status.

      📝 What's Changed

      See CHANGELOG.md for details.

    README 原文

    未翻译

    Crawl4AI Cloud is a hosted web scraping, extraction, and search API for AI agents and data pipelines. Turn pages into clean Markdown for RAG, extract structured JSON, or search the live web with one API key. Crawl4AI runs the browsers and manages the proxies.

    Get a free API key · 1,000 free credits every month. No credit card required.

    Try a URL in the playground · Set up Crawl4AI Cloud in Claude Code, Cursor, or Codex

    This repository is home to the Apache-2.0 crawler that powers Crawl4AI Cloud. Run it yourself with Python or Docker.

    GitHub Stars PyPI version Downloads Discord

    Cloud quickstart

    Hosted API base URL: https://api.crawl4ai.com.

    Cloud API reference · Agent setup and MCP

    Set CRAWL4AI_KEY to your API key, then scrape a page as Markdown:

    curl -s https://api.crawl4ai.com/scrape \
      -H "Authorization: Bearer $CRAWL4AI_KEY" \
      -H "Content-Type: application/json" \
      -d '{"url": "https://news.ycombinator.com"}' | jq -r .markdown
    
    import json
    import os
    from urllib.request import Request, urlopen
    
    request = Request(
        "https://api.crawl4ai.com/scrape",
        data=json.dumps({"url": "https://news.ycombinator.com"}).encode("utf-8"),
        headers={
            "Authorization": f"Bearer {os.environ['CRAWL4AI_KEY']}",
            "Content-Type": "application/json",
        },
        method="POST",
    )
    
    with urlopen(request) as response:
        print(json.load(response)["markdown"])
    
    async function main() {
      const key = process.env.CRAWL4AI_KEY;
      if (!key) throw new Error("Set CRAWL4AI_KEY first.");
    
      const response = await fetch("https://api.crawl4ai.com/scrape", {
        method: "POST",
        headers: {
          Authorization: `Bearer ${key}`,
          "Content-Type": "application/json",
        },
        body: JSON.stringify({ url: "https://news.ycombinator.com" }),
      });
    
      if (!response.ok) {
        throw new Error(`Scrape failed (HTTP ${response.status}): ${await response.text()}`);
      }
    
      const { markdown } = await response.json();
      console.log(markdown);
    }
    
    main().catch((error) => {
      console.error(error.message);
      process.exitCode = 1;
    });
    

    Example Markdown output (illustrative excerpt):

    # Hacker News
    
    1. [Example story title](https://example.com/story)
    2. [Another story title](https://example.com/another-story)
    

    The same key works for /extract, /search, /serp, /answer and many URLs at once (/scrape/batch, /scrape/jobs). Pay as you go: live prices. For Claude Code, connect to the hosted MCP server:

    claude mcp add --transport http crawl4ai https://api.crawl4ai.com/mcp \
      --header "Authorization: Bearer $CRAWL4AI_KEY"
    

    Run Crawl4AI yourself

    Latest: v0.9.5 (14 Oct 2026) · all releases →

    pip install -U crawl4ai
    crawl4ai-setup        # installs the browser, once
    
    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())
    

    Docker server, CLI and every option: Installation · Self-hosted docs

    Which one?

    ☁️ Crawl4AI Cloud🐍 Library🐳 Your own server
    Runs the browserswe doyou, in your Python processyou, in Docker on your machine
    JS-heavy pages and bot wallshandled for you, automaticallyyour settings, your proxiesyour settings, your proxies
    Web search/search, /serp and /answer––
    Price1,000 free credits a month; plans from $10Free, Apache-2.0. You cover infrastructure.Free, Apache-2.0. You cover hosting.

    I grew up on an Amstrad, thanks to my dad, and never stopped building. In grad school I specialized in NLP and built crawlers for research. That’s where I learned how much extraction matters.

    In 2023, I needed web-to-Markdown. The “open source” option wanted an account, API token, and $16, and still under-delivered. I went turbo anger mode, built Crawl4AI in days, and it went viral.

    I made it open source for availability, anyone can use it without a gate. Now I’m building the platform for affordability, anyone can run serious crawls without breaking the bank. If that resonates, join in, send feedback, or just crawl something amazing.

    That platform is live now: Crawl4AI Cloud.

    • LLM-ready output: smart Markdown with headings, tables, code and citation hints
    • Fast in practice: async browser pool, caching, minimal hops
    • Full control: sessions, proxies, cookies, user scripts, hooks
    • Adaptive intelligence: learns site patterns, explores only what matters
    • Deploy anywhere: run locally with Python or the CLI, secure your Docker server with a self-managed token, or use a Crawl4AI Cloud API key.

    ✨ Features

    • 🧹 Clean Markdown: headings, lists, tables and code blocks, in a structure an LLM reads well.
    • 🎯 Fit Markdown: filters remove menus, footers and boilerplate: PruningContentFilterLXML, BM25ContentFilter (for a query) and LLMContentFilter.
    • 🔗 Citations: page links become a numbered reference list.
    • 🛠️ Your own strategy: plug in a custom Markdown generator.

    ☁️ Same in the cloud: POST /scrape returns this Markdown, with no browser to run. Docs →

    • 🔎 CSS and XPath schemas: fast extraction with no LLM (JsonCssExtractionStrategy, JsonXPathExtractionStrategy, RegexExtractionStrategy).
    • 🪄 Schema generator: describe what you want once; generate_schema writes a reusable schema.
    • 🤖 LLM extraction: any LLM provider, open-source or hosted, into a typed JSON schema (LLMExtractionStrategy).
    • 🧱 Chunking: topic, regex and sentence chunking for long pages.
    • 🌌 Cosine similarity: find the chunks that match a query (CosineStrategy).

    ☁️ Same in the cloud: POST /extract, with no LLM key of your own. Docs →

    • 🖥️ Your own browser: persistent profiles with saved logins, cookies and settings.
    • 🔄 Remote browsers: connect over the Chrome DevTools Protocol (CDP).
    • 🔒 Sessions: keep a browser state across multi-step crawls.
    • 🧩 Proxies: with authentication and rotation.
    • 🕶️ Stealth mode: enable_stealth, and an undetected-browser adapter for sites that detect automation.
    • ⚙️ Full control: headers, cookies, user agents, viewport.
    • 🌍 Chromium, Firefox and WebKit.
    • 🕸️ Deep crawl: BFS, DFS and best-first strategies, with crash recovery (resume_state) for long crawls.
    • 🧠 Adaptive crawling: AdaptiveCrawler stops when it has learned enough to answer your query.
    • 🌱 URL discovery: AsyncUrlSeeder (sitemaps, Common Crawl) and DomainMapper; prefetch=True finds URLs 5 to 10 times faster.
    • 🚀 Dynamic pages: run JavaScript, wait for elements, scroll the full page (scan_full_page) for infinite scroll and lazy images.
    • 📸 Screenshots and PDFs of any page.
    • 🖼️ Media and links: images, audio, video, srcset, internal and external links, iframes, metadata.
    • 📂 Raw HTML and local files: raw: and file://.
    • 🛠️ Hooks at every step of a crawl.
    • 💾 Caching to skip repeated fetches.
    • ⚡ Many URLs at once: arun_many with a memory-adaptive dispatcher.

    ☁️ Same in the cloud: up to 50 URLs in one streamed call, or 10,000 in a background job. Docs →

    • 🔐 Secure by default: every endpoint needs your CRAWL4AI_API_TOKEN.
    • 🧰 REST API: /md, /html, /crawl, /crawl/stream, /screenshot, /pdf, /execute_js.
    • 🤖 MCP: connect Claude Code and other agents to your own server.
    • 📊 Monitoring dashboard and playground, a browser pool with pre-warmed pages.
    • 🏗️ AMD64 and ARM64 images.

    ☁️ Rather not run a server? The cloud is the same idea, hosted. Get a key →

    • 🔍 Web search API: GET /search, browser-free, ranked and cleaned. Docs →
    • 📊 SERP API: GET /serp, Google's results page as data: true ranks, every block, localised to a place. Beta. Docs →
    • 💬 Answers: GET /answer gives a direct answer to a question (experimental). Docs →
    • 🧪 Extraction without your own LLM key: POST /extract. Docs →
    • 🧗 JS-heavy pages and bot walls: handled automatically; you never pick an engine. Docs →
    • 🤝 MCP for your agent: one line in Claude Code, Codex, Cursor or OpenCode. Docs →

    🛠️ Installation

    pip install -U crawl4ai
    crawl4ai-setup      # installs and sets up the browser
    crawl4ai-doctor     # checks the installation
    

    If the browser setup fails, install it by hand:

    python -m playwright install --with-deps chromium
    

    Pre-release versions: pip install crawl4ai --pre

    Development install, for contributors:

    git clone https://github.com/unclecode/crawl4ai.git
    cd crawl4ai
    pip install -e ".[all]"     # or: pip install -e .   (the core only)
    

    The server needs a token. Without one it answers only inside its container.

    export CRAWL4AI_API_TOKEN="$(openssl rand -hex 32)"
    docker run -d -p 11235:11235 --name crawl4ai --shm-size=1g \
      -e CRAWL4AI_API_TOKEN="$CRAWL4AI_API_TOKEN" \
      unclecode/crawl4ai:latest
    

    Test it (allow about 10 seconds for the start):

    curl -s http://localhost:11235/md \
      -H "Authorization: Bearer $CRAWL4AI_API_TOKEN" \
      -H "Content-Type: application/json" \
      -d '{"url": "https://news.ycombinator.com"}' | jq -r .markdown
    

    The dashboard is at http://localhost:11235/dashboard, the playground at http://localhost:11235/playground. LLM keys, MCP and every setting: Self-hosting guide.

    # A page as Markdown
    crwl https://news.ycombinator.com -o markdown
    
    # Deep crawl, breadth first, at most 10 pages
    crwl https://docs.crawl4ai.com --deep-crawl bfs --max-pages 10
    
    # Ask a question about a page (needs an LLM key: crwl config)
    crwl https://www.example.com/products -q "Extract all product prices"
    

    🔬 Advanced usage examples

    More in docs/examples.

    import asyncio
    from crawl4ai import AsyncWebCrawler, BrowserConfig, CrawlerRunConfig, CacheMode
    from crawl4ai.content_filter_strategy import PruningContentFilterLXML
    from crawl4ai.markdown_generation_strategy import DefaultMarkdownGenerator
    
    async def main():
        run_config = CrawlerRunConfig(
            cache_mode=CacheMode.BYPASS,
            markdown_generator=DefaultMarkdownGenerator(
                content_filter=PruningContentFilterLXML(threshold=0.48, threshold_type="fixed", min_word_threshold=0)
            ),
        )
        async with AsyncWebCrawler(config=BrowserConfig(headless=True)) as crawler:
            result = await crawler.arun(url="https://en.wikipedia.org/wiki/Web_crawler", config=run_config)
            print(len(result.markdown.raw_markdown), "characters of raw Markdown")
            print(len(result.markdown.fit_markdown), "characters after the filter")
    
    asyncio.run(main())
    
    import asyncio, json
    from crawl4ai import AsyncWebCrawler, BrowserConfig, CrawlerRunConfig, CacheMode, JsonCssExtractionStrategy
    
    schema = {
        "name": "Quotes",
        "baseSelector": "div.quote",
        "fields": [
            {"name": "text", "selector": "span.text", "type": "text"},
            {"name": "author", "selector": "small.author", "type": "text"},
            {"name": "tags", "selector": "a.tag", "type": "list", "fields": [{"name": "tag", "type": "text"}]},
        ],
    }
    
    async def main():
        run_config = CrawlerRunConfig(
            extraction_strategy=JsonCssExtractionStrategy(schema),
            scan_full_page=True,   # scroll to the end, so the page loads every quote
            scroll_delay=0.5,
            cache_mode=CacheMode.BYPASS,
        )
        async with AsyncWebCrawler(config=BrowserConfig(headless=True)) as crawler:
            result = await crawler.arun(url="https://quotes.toscrape.com/scroll", config=run_config)
            quotes = json.loads(result.extracted_content)
            print(f"Extracted {len(quotes)} quotes")
            print(json.dumps(quotes[0], indent=2))
    
    asyncio.run(main())
    
    import os, asyncio
    from pydantic import BaseModel, Field
    from crawl4ai import AsyncWebCrawler, CrawlerRunConfig, CacheMode, LLMConfig, LLMExtractionStrategy
    
    class ModelFee(BaseModel):
        model_name: str = Field(..., description="Name of the model.")
        input_fee: str = Field(..., description="Fee for input tokens.")
        output_fee: str = Field(..., description="Fee for output tokens.")
    
    async def main():
        run_config = CrawlerRunConfig(
            cache_mode=CacheMode.BYPASS,
            extraction_strategy=LLMExtractionStrategy(
                # any provider LiteLLM supports, e.g. "ollama/llama3.3" with api_token="no-token"
                llm_config=LLMConfig(provider="openai/gpt-4o-mini", api_token=os.getenv("OPENAI_API_KEY")),
                schema=ModelFee.model_json_schema(),
                extraction_type="schema",
                instruction="Extract every model name with its input and output token fee.",
            ),
        )
        async with AsyncWebCrawler() as crawler:
            result = await crawler.arun(url="https://openai.com/api/pricing/", config=run_config)
            print(result.extracted_content)
    
    asyncio.run(main())
    
    import os, asyncio
    from pathlib import Path
    from crawl4ai import AsyncWebCrawler, BrowserConfig, CrawlerRunConfig, CacheMode
    
    async def main():
        user_data_dir = os.path.join(Path.home(), ".crawl4ai", "browser_profile")
        os.makedirs(user_data_dir, exist_ok=True)
        browser_config = BrowserConfig(headless=True, user_data_dir=user_data_dir, use_persistent_context=True)
        run_config = CrawlerRunConfig(cache_mode=CacheMode.BYPASS, magic=True)
        async with AsyncWebCrawler(config=browser_config) as crawler:
            result = await crawler.arun(url="ADDRESS_OF_A_CHALLENGING_WEBSITE", config=run_config)
            print(result.success, len(result.markdown))
    
    asyncio.run(main())
    

    📖 Documentation

    🤝 Contributing

    We welcome contributions from the open-source community. Check out our contribution guidelines for more information.

    📄 License & Attribution

    This project is licensed under the Apache License 2.0, attribution is recommended via the badges below. See the Apache 2.0 License file for details.

    Attribution Requirements

    When using Crawl4AI, you must include one of the following attribution methods:

    ThemeBadge
    Disco Theme (Animated)
    Night Theme (Dark with Neon)
    Dark Theme (Classic)
    Light Theme (Classic)

    HTML code for adding the badges:

    <!-- Disco Theme (Animated) -->
    <a href="https://github.com/unclecode/crawl4ai">
      <img src="https://raw.githubusercontent.com/unclecode/crawl4ai/main/docs/assets/powered-by-disco.svg" alt="Powered by Crawl4AI" width="200"/>
    </a>
    
    <!-- Night Theme (Dark with Neon) -->
    <a href="https://github.com/unclecode/crawl4ai">
      <img src="https://raw.githubusercontent.com/unclecode/crawl4ai/main/docs/assets/powered-by-night.svg" alt="Powered by Crawl4AI" width="200"/>
    </a>
    
    <!-- Dark Theme (Classic) -->
    <a href="https://github.com/unclecode/crawl4ai">
      <img src="https://raw.githubusercontent.com/unclecode/crawl4ai/main/docs/assets/powered-by-dark.svg" alt="Powered by Crawl4AI" width="200"/>
    </a>
    
    <!-- Light Theme (Classic) -->
    <a href="https://github.com/unclecode/crawl4ai">
      <img src="https://raw.githubusercontent.com/unclecode/crawl4ai/main/docs/assets/powered-by-light.svg" alt="Powered by Crawl4AI" width="200"/>
    </a>
    
    <!-- Simple Shield Badge -->
    <a href="https://github.com/unclecode/crawl4ai">
      <img src="https://img.shields.io/badge/Powered%20by-Crawl4AI-blue?style=flat-square" alt="Powered by Crawl4AI"/>
    </a>
    

    📚 Citation

    If you use Crawl4AI in your research or project, please cite:

    @software{crawl4ai2024,
      author = {UncleCode},
      title = {Crawl4AI: Open-source LLM Friendly Web Crawler & Scraper},
      year = {2024},
      publisher = {GitHub},
      journal = {GitHub Repository},
      howpublished = {\url{https://github.com/unclecode/crawl4ai}},
      commit = {Please use the commit hash you're working with}
    }
    

    Text citation format:

    UncleCode. (2024). Crawl4AI: Open-source LLM Friendly Web Crawler & Scraper [Computer software]. 
    GitHub. https://github.com/unclecode/crawl4ai
    

    🗾 Mission

    Our mission is to unlock the value of personal and enterprise data by turning digital footprints into structured, useful assets. Crawl4AI gives individuals and organizations open-source tools to extract and structure data, and a fair way to benefit from it. Full mission statement →

    💖 Support Crawl4AI

    1. ⭐ Star the repo: it helps more people find it.
    2. ☁️ Use the cloud: crawl4ai.com. It funds the library.
    3. 💝 Sponsor on GitHub: github.com/sponsors/unclecode
    4. 🏢 Companies: the sponsor tiers and benefits are in SPONSORS.md.

    🌟 Current Sponsors

    🤝 Strategic Partners

    These companies provide core infrastructure and technology that power Crawl4AI’s capabilities — from web access and proxy networks to AI tooling and data pipelines.

    CompanyAbout
    Massive provides a web access API for AI agents and data pipelines. Partnership details.

    🏢 Enterprise Sponsors

    Our enterprise sponsors support Crawl4AI and help scale it to power production-grade data pipelines.

    CompanyAboutSponsorship Tier
    Helps engineers and buyers find, compare, and source electronic & industrial parts in seconds, with specs, pricing, lead times & alternatives.🥇 Gold
    Kidocode is a hybrid technology and entrepreneurship school for kids aged 5–18, offering both online and on-campus education.🥇 Gold
    Singapore-based Aleph Null is Asia’s leading edtech hub, dedicated to student-centric, AI-driven education—empowering learners with the tools to thrive in a fast-changing world.🥇 Gold

    💼 Become a Strategic Partner or Sponsor

    Interested in partnering with Crawl4AI?

    Whether you’re a proxy provider, AI infrastructure company, cloud platform, or an organization looking to support the Crawl4AI ecosystem, we’d love to hear from you.

    📩 Contact: [email protected]

    🧑‍🤝 Individual Sponsors

    A heartfelt thanks to our individual supporters! Every contribution helps us keep our opensource mission alive and thriving!

    Want to join them? Sponsor Crawl4AI →

    📧 Contact

    Discord · X @unclecode · GitHub @unclecode · [email protected]

    • Building crawlers or AI agents for a living? DM me on X. I want to work with people like you, and we are hiring.
    • From a company? We have an enterprise offer and we tailor it to your business. See our security and compliance page for current details. Write to [email protected].

    Happy crawling! 🕸️🚀

    Star History