crawlee-python

apifyApache-2.0活跃维护

Python 网页抓取与浏览器自动化库,支持 Playwright、BeautifulSoup 和原始 HTTP,自带代理轮换,方便为 AI、LLM、RAG 稳定采集网页数据。

Crawlee—A web scraping and browser automation library for Python to build reliable crawlers. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Parsel, BeautifulSoup, Playwright, and raw HTTP. Both headful and headless mode. With proxy rotation.

v1.11.1发布于 2026-11-05 14:36 UTC9,657star +1 / 7 天826fork同步于 2026-11-10 05:30 UTC

怎么上手

由 README 提炼,执行前请确认
python -m pip install 'crawlee[all]'
playwright install
硬件要求按 README 说明

README 未说明显存或 GPU 要求;PlaywrightCrawler 需本地安装 Playwright 浏览器依赖,BeautifulSoupCrawler 走纯 HTTP 无需浏览器。

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

项目说明

由 README 自动翻译提炼

Python 爬虫与浏览器自动化库,帮你快速搭出可靠、抗封的抓取流水线

Python 网页抓取与浏览器自动化库,支持 Playwright、BeautifulSoup 和原始 HTTP,自带代理轮换,方便为 AI、LLM、RAG 稳定采集网页数据。

核心能力

  • 统一 HTTP 与无头浏览器两种抓取接口
  • 按系统资源自动并行爬取并自动重试
  • 内置代理轮换与会话管理降低被封风险
  • 可配置请求路由把 URL 分发给对应处理器
  • 持久化 URL 队列与数据集、键值存储

容易踩的坑

默认安装只含核心功能,用 BeautifulSoup 或 Playwright 爬虫需装对应 extra;用 PlaywrightCrawler 前必须额外执行 playwright install 下载浏览器;运行后会在当前工作目录生成 storage/ 目录存放数据。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v1.11.1
  1. v1.11.11.11.1最新正式版2026-11-05 · 2026-11-05 14:36 UTC

    1.11.1 (2026-11-05)

    🐛 Bug Fixes

    • Ignore a UTF-8 byte order mark in robots.txt (#2351) (3e6ee66) by @RaphaelFakhri
    • deps: Drop the upper bound on sqlalchemy (#2356) (cadd810) by @vdusek
    • sitemap: Join element text once and reject entity declarations (#2369) (242be00) by @vdusek
    • browsers: Remove the persistent browser's temp directory after the browser exits (#2381) (06d331b) by @vdusek

    ⚡ Performance

    • Make html_to_text linear in the number of nodes (#2372) (26e7612) by @B4nan
  2. v1.11.01.11.02026-10-15 · 2026-10-15 08:38 UTC
    查看更新说明

    1.11.0 (2026-10-15)

    🚀 Features

    • storages: Add direct async iteration on Dataset and KeyValueStore (#2267) (e02e71d) by @Pijukatel
    • crawlers: Add extract_form_requests helper for HTTP crawlers with HTML parsers (#2257) (62386fd) by @Mantisus
    • Add support for Python 3.15 (#2294) (680c7ef) by @vdusek

    🐛 Bug Fixes

    • deps: Replace jaro-winkler with RapidFuzz in the adaptive-crawler extra (#2282) (81ab674) by @Mantisus

    ⚡ Performance

    • Replace tldextract with a built-in Public Suffix List lookup (#2283) (a14f745) by @Mantisus
  3. v1.10.41.10.42026-10-06 · 2026-10-06 08:22 UTC
    查看更新说明

    1.10.4 (2026-10-06)

    🐛 Bug Fixes

    • crawlers: Parse HTML responses starting with an XML declaration as HTML in ParselCrawler (#2262) (df1178c) by @Mantisus
    • crawlers: Resolve relative and invalid base URLs when extracting links (#2263) (c69f75f) by @Mantisus
    • crawlers: Detect JSON served as text/html and handle empty responses in ParselCrawler (#2266) (3a58843) by @Mantisus
    • Make crawlee[all] installable with pip<26 (#2270) (87561ee) by @vdusek
    • Pause the crawl on Ctrl+C on Windows instead of crashing (#2277) (dbec1f5) by @Mantisus
  4. v1.10.31.10.32026-09-29 · 2026-09-29 10:50 UTC
    查看更新说明

    1.10.3 (2026-09-29)

    🐛 Bug Fixes

    • Make JsonSerializable type alias read-only (#2249) (dd7358f) by @Pijukatel
    • Use container memory and CPU limits when running in a container (#2128) (40dafe5) by @Mantisus
    • crawlers: Keep the crawler usable after a failed run (#2255) (3e73166) by @vdusek
    • browsers: Retry the temp directory removal until the browser releases its files (#2239) (8f41522) by @vdusek
    • throttling-manager: Defer throttled 429s without spending retries and give up on persistently rate-limited domains (#2250) (6b7db66) by @Mantisus
    • crawlers: Decode non-UTF-8 pages correctly in ParselCrawler and BeautifulSoupCrawler (#2260) (209e8a1) by @Mantisus
  5. v1.10.21.10.22026-09-22 · 2026-09-22 12:08 UTC
    查看更新说明

    1.10.2 (2026-09-22)

    🐛 Bug Fixes

    • Make extra_name of try_import optional and the install hint reusable (#2247) (626f334) by @Pijukatel

用户点评

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

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

    README 原文

    未翻译

    Crawlee covers your crawling and scraping end-to-end and helps you build reliable scrapers. Fast.

    Your crawlers will appear almost human-like and fly under the radar of modern bot protections even with the default configuration. Crawlee gives you the tools to crawl the web for links, scrape data and persistently store it in machine-readable formats, without having to worry about the technical details. And thanks to rich configuration options, you can tweak almost any aspect of Crawlee to suit your project's needs if the default settings don't cut it.

    👉 View full documentation, guides and examples on the Crawlee project website 👈

    We also have a TypeScript implementation of the Crawlee, which you can explore and utilize for your projects. Visit our GitHub repository for more information Crawlee for JS/TS on GitHub.

    Installation

    We recommend visiting the Introduction tutorial in Crawlee documentation for more information.

    Crawlee is available as crawlee package on PyPI. This package includes the core functionality, while additional features are available as optional extras to keep dependencies and package size minimal.

    To install Crawlee with all features, run the following command:

    python -m pip install 'crawlee[all]'
    

    Then, install the Playwright dependencies:

    playwright install
    

    Verify that Crawlee is successfully installed:

    python -c 'import crawlee; print(crawlee.__version__)'
    

    For detailed installation instructions see the Setting up documentation page.

    With Crawlee CLI

    The quickest way to get started with Crawlee is by using the Crawlee CLI and selecting one of the prepared templates. First, ensure you have uv installed:

    uv --help
    

    If uv is not installed, follow the official installation guide.

    Then, run the CLI and choose from the available templates:

    uvx 'crawlee[cli]' create my-crawler
    

    If you already have crawlee installed, you can spin it up by running:

    crawlee create my-crawler
    

    Examples

    Here are some practical examples to help you get started with different types of crawlers in Crawlee. Each example demonstrates how to set up and run a crawler for specific use cases, whether you need to handle simple HTML pages or interact with JavaScript-heavy sites. A crawler run will create a storage/ directory in your current working directory.

    BeautifulSoupCrawler

    The BeautifulSoupCrawler downloads web pages using an HTTP library and provides HTML-parsed content to the user. By default it uses ImpitHttpClient for HTTP communication and BeautifulSoup for parsing HTML. It is ideal for projects that require efficient extraction of data from HTML content. This crawler has very good performance since it does not use a browser. However, if you need to execute client-side JavaScript, to get your content, this is not going to be enough and you will need to use PlaywrightCrawler. Also if you want to use this crawler, make sure you install crawlee with beautifulsoup extra.

    import asyncio
    
    from crawlee.crawlers import BeautifulSoupCrawler, BeautifulSoupCrawlingContext
    
    
    async def main() -> None:
        crawler = BeautifulSoupCrawler(
            # Limit the crawl to max requests. Remove or increase it for crawling all links.
            max_requests_per_crawl=10,
        )
    
        # Define the default request handler, which will be called for every request.
        @crawler.router.default_handler
        async def request_handler(context: BeautifulSoupCrawlingContext) -> None:
            context.log.info(f'Processing {context.request.url} ...')
    
            # Extract data from the page.
            data = {
                'url': context.request.url,
                'title': context.soup.title.string if context.soup.title else None,
            }
    
            # Push the extracted data to the default dataset.
            await context.push_data(data)
    
            # Enqueue all links found on the page.
            await context.enqueue_links()
    
        # Run the crawler with the initial list of URLs.
        await crawler.run(['https://crawlee.dev'])
    
    
    if __name__ == '__main__':
        asyncio.run(main())
    

    PlaywrightCrawler

    The PlaywrightCrawler uses a headless browser to download web pages and provides an API for data extraction. It is built on Playwright, an automation library designed for managing headless browsers. It excels at retrieving web pages that rely on client-side JavaScript for content generation, or tasks requiring interaction with JavaScript-driven content. For scenarios where JavaScript execution is unnecessary or higher performance is required, consider using the BeautifulSoupCrawler. Also if you want to use this crawler, make sure you install crawlee with playwright extra.

    import asyncio
    
    from crawlee.crawlers import PlaywrightCrawler, PlaywrightCrawlingContext
    
    
    async def main() -> None:
        crawler = PlaywrightCrawler(
            # Limit the crawl to max requests. Remove or increase it for crawling all links.
            max_requests_per_crawl=10,
        )
    
        # Define the default request handler, which will be called for every request.
        @crawler.router.default_handler
        async def request_handler(context: PlaywrightCrawlingContext) -> None:
            context.log.info(f'Processing {context.request.url} ...')
    
            # Extract data from the page.
            data = {
                'url': context.request.url,
                'title': await context.page.title(),
            }
    
            # Push the extracted data to the default dataset.
            await context.push_data(data)
    
            # Enqueue all links found on the page.
            await context.enqueue_links()
    
        # Run the crawler with the initial list of requests.
        await crawler.run(['https://crawlee.dev'])
    
    
    if __name__ == '__main__':
        asyncio.run(main())
    

    More examples

    Explore the Guides section of the Crawlee documentation for a wide range of additional use cases and demonstrations.

    Features

    Why Crawlee is the preferred choice for web scraping and crawling?

    Why use Crawlee instead of just a random HTTP library with an HTML parser?

    • Unified interface for HTTP & headless browser crawling.
    • Automatic parallel crawling based on available system resources.
    • Written in Python with type hints - enhances DX (IDE autocompletion) and reduces bugs (static type checking).
    • Automatic retries on errors or when you’re getting blocked.
    • Integrated proxy rotation and session management.
    • Configurable request routing - direct URLs to the appropriate handlers.
    • Persistent queue for URLs to crawl.
    • Pluggable storage of both tabular data and files.
    • Robust error handling.

    Why to use Crawlee rather than Scrapy?

    • Asyncio-based – Leveraging the standard Asyncio library, Crawlee delivers better performance and seamless compatibility with other modern asynchronous libraries.
    • Type hints – Newer project built with modern Python, and complete type hint coverage for a better developer experience.
    • Simple integration – Crawlee crawlers are regular Python scripts, requiring no additional launcher executor. This flexibility allows to integrate a crawler directly into other applications.
    • State persistence – Supports state persistence during interruptions, saving time and costs by avoiding the need to restart scraping pipelines from scratch after an issue.
    • Organized data storages – Allows saving of multiple types of results in a single scraping run. Offers several storing options (see datasets & key-value stores).

    Running on the Apify platform

    Crawlee is open-source and runs anywhere, but since it's developed by Apify, it's easy to set up on the Apify platform and run in the cloud. Visit the Apify SDK website to learn more about deploying Crawlee to the Apify platform.

    Support

    If you find any bug or issue with Crawlee, please submit an issue on GitHub. For questions, you can ask on Stack Overflow, in GitHub Discussions or you can join our Discord server.

    Contributing

    Your code contributions are welcome, and you'll be praised for eternity! If you have any ideas for improvements, either submit an issue or create a pull request. For contribution guidelines and the code of conduct, see CONTRIBUTING.md.

    License

    This project is licensed under the Apache License 2.0 - see the LICENSE file for details.