MCPcopy
hub / github.com/apify/crawlee

github.com/apify/crawlee @v3.17.0 sqlite

repository ↗ · DeepWiki ↗ · release v3.17.0 ↗
2,689 symbols 10,702 edges 1,266 files 522 documented · 19%
README

Crawlee A web scraping and browser automation library

<a href="https://trendshift.io/repositories/5179" target="_blank"><img src="https://trendshift.io/api/badge/repositories/5179" alt="apify%2Fcrawlee | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>







<a href="https://www.npmjs.com/package/@crawlee/core" rel="nofollow"><img src="https://img.shields.io/npm/v/@crawlee/core.svg" alt="NPM latest version" data-canonical-src="https://img.shields.io/npm/v/@crawlee/core/next.svg" style="max-width: 100%;"></a>
<a href="https://www.npmjs.com/package/@crawlee/core" rel="nofollow"><img src="https://img.shields.io/npm/dm/@crawlee/core.svg" alt="Downloads" data-canonical-src="https://img.shields.io/npm/dm/@crawlee/core.svg" style="max-width: 100%;"></a>
<a href="https://discord.gg/jyEM2PRvMU" rel="nofollow"><img src="https://img.shields.io/discord/801163717915574323?label=discord" alt="Chat on discord" data-canonical-src="https://img.shields.io/discord/801163717915574323?label=discord" style="max-width: 100%;"></a>
<a href="https://github.com/apify/crawlee/actions/workflows/test-ci.yml"><img src="https://github.com/apify/crawlee/actions/workflows/test-ci.yml/badge.svg?branch=master" alt="Build Status" style="max-width: 100%;"></a>

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

Your crawlers will appear 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 store it to disk or cloud while staying configurable to suit your project's needs.

Crawlee is available as the crawlee NPM package.

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

Do you prefer 🐍 Python instead of JavaScript? 👉 Checkout Crawlee for Python 👈.

Installation

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

Crawlee requires Node.js 16 or higher.

With Crawlee CLI

The fastest way to try Crawlee out is to use the Crawlee CLI and choose the Getting started example. The CLI will install all the necessary dependencies and add boilerplate code for you to play with.

npx crawlee create my-crawler
cd my-crawler
npm start

Manual installation

If you prefer adding Crawlee into your own project, try the example below. Because it uses PlaywrightCrawler we also need to install Playwright. It's not bundled with Crawlee to reduce install size.

npm install crawlee playwright
import { PlaywrightCrawler, Dataset } from 'crawlee';

// PlaywrightCrawler crawls the web using a headless
// browser controlled by the Playwright library.
const crawler = new PlaywrightCrawler({
    // Use the requestHandler to process each of the crawled pages.
    async requestHandler({ request, page, enqueueLinks, log }) {
        const title = await page.title();
        log.info(`Title of ${request.loadedUrl} is '${title}'`);

        // Save results as JSON to ./storage/datasets/default
        await Dataset.pushData({ title, url: request.loadedUrl });

        // Extract links from the current page
        // and add them to the crawling queue.
        await enqueueLinks();
    },
    // Uncomment this option to see the browser window.
    // headless: false,
});

// Add first URL to the queue and start the crawl.
await crawler.run(['https://crawlee.dev']);

By default, Crawlee stores data to ./storage in the current working directory. You can override this directory via Crawlee configuration. For details, see Configuration guide, Request storage and Result storage.

Installing pre-release versions

We provide automated beta builds for every merged code change in Crawlee. You can find them in the npm list of releases. If you want to test new features or bug fixes before we release them, feel free to install a beta build like this:

npm install crawlee@next

If you also use the Apify SDK, you need to specify dependency overrides in your package.json file so that you don't end up with multiple versions of Crawlee installed:

{
    "overrides": {
       "apify": {
           "@crawlee/core": "$crawlee",
           "@crawlee/types": "$crawlee",
           "@crawlee/utils": "$crawlee"
       }
    }
}

🛠 Features

  • Single interface for HTTP and headless browser crawling
  • Persistent queue for URLs to crawl (breadth & depth first)
  • Pluggable storage of both tabular data and files
  • Automatic scaling with available system resources
  • Integrated proxy rotation and session management
  • Lifecycles customizable with hooks
  • CLI to bootstrap your projects
  • Configurable routing, error handling and retries
  • Dockerfiles ready to deploy
  • Written in TypeScript with generics

👾 HTTP crawling

  • Zero config HTTP2 support, even for proxies
  • Automatic generation of browser-like headers
  • Replication of browser TLS fingerprints
  • Integrated fast HTML parsers. Cheerio and JSDOM
  • Yes, you can scrape JSON APIs as well

💻 Real browser crawling

  • JavaScript rendering and screenshots
  • Headless and headful support
  • Zero-config generation of human-like fingerprints
  • Automatic browser management
  • Use Playwright and Puppeteer with the same interface
  • Chrome, Firefox, Webkit and many others

Usage 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 to 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.md file for details.

Extension points exported contracts — how you extend this code

FileLike (Interface)
* This is copied from https://github.com/octet-stream/form-data-encoder [9 implementers]
packages/core/src/http_clients/form-data-like.ts
PeekableAsyncIterable (Interface)
(no doc) [6 implementers]
packages/utils/src/internals/iterables.ts
StorageImplementation (Interface)
(no doc) [9 implementers]
packages/memory-storage/src/fs/common.ts
DatasetCollectionClient (Interface)
(no doc) [3 implementers]
packages/types/src/storages.ts
EnqueueLinksInternalOptions (Interface)
@internal
packages/browser-crawler/src/internals/browser-crawler.ts
CommonBrowser (Interface)
(no doc) [2 implementers]
packages/browser-pool/src/abstract-classes/browser-plugin.ts
BasicCrawlingContext (Interface)
(no doc) [1 implementers]
packages/basic-crawler/src/internals/basic-crawler.ts
InternalHttpCrawlingContext (Interface)
(no doc) [1 implementers]
packages/http-crawler/src/internals/http-crawler.ts

Core symbols most depended-on inside this repo

expect
called by 3325
test/e2e/tools.mjs
run
called by 712
packages/core/src/crawlers/statistics.ts
push
called by 490
packages/core/src/autoscaling/load_signal.ts
enqueueLinks
called by 324
packages/core/src/enqueue_links/enqueue_links.ts
open
called by 315
packages/core/src/storages/dataset.ts
map
called by 314
packages/core/src/storages/dataset.ts
log
called by 312
packages/basic-crawler/src/internals/basic-crawler.ts
addRequests
called by 250
packages/core/src/storages/request_queue_v2.ts

Shape

Function 1,233
Method 937
Interface 285
Class 224
Enum 9
Route 1

Languages

TypeScript100%
Python1%

Modules by API surface

packages/types/src/storages.ts88 symbols
packages/basic-crawler/src/internals/basic-crawler.ts70 symbols
packages/core/src/storages/request_provider.ts49 symbols
packages/core/src/storages/request_list.ts41 symbols
packages/puppeteer-crawler/src/internals/utils/puppeteer_utils.ts40 symbols
packages/playwright-crawler/src/internals/utils/playwright-utils.ts40 symbols
packages/playwright-crawler/src/internals/adaptive-playwright-crawler.ts35 symbols
packages/core/src/storages/dataset.ts33 symbols
packages/browser-pool/src/browser-pool.ts33 symbols
packages/puppeteer-crawler/src/internals/enqueue-links/click-elements.ts30 symbols
packages/core/src/session_pool/session.ts29 symbols
packages/playwright-crawler/src/internals/enqueue-links/click-elements.ts28 symbols

Used by 1 indexed graphs manifest dependencies, hub-wide

Dependencies from manifests, versioned

@apify/consts2.20.0 · 1×
@apify/datastructures2.0.3 · 1×
@apify/docusaurus-plugin-typedoc-api5.1.7 · 1×
@apify/eslint-config2.0.0 · 1×
@apify/eslint-config-ts0.4.0 · 1×
@apify/log2.4.0 · 1×
@apify/ps-tree1.2.0 · 1×
@apify/pseudo_url2.0.30 · 1×
@apify/storage-local3.0.0 · 1×
@apify/timeout0.3.1 · 1×
@apify/tsconfig0.1.0 · 1×
@apify/ui-icons1.23.0 · 1×

For agents

$ claude mcp add crawlee \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact