Zurück zum Ranking

yujiosaka/headless-chrome-crawler

JavaScript

Distributed crawler powered by Headless Chrome

headless-chromepuppeteerjquerycrawlercrawlingscraperscrapingchromechromiumpromise
Sterne-Wachstum
Sterne
5.6k
Forks
404
Wochenwachstum
Issues
29
2k4k
Dez. 2017Okt. 2020Sept. 2023Juli 2026
Artefaktenpmnpm install headless-chrome-crawler
README

Headless Chrome Crawler npm build Greenkeeper badge

API | Examples | Tips | Code of Conduct | Contributing | Changelog

Distributed crawler powered by Headless Chrome

Features

Crawlers based on simple requests to HTML files are generally fast. However, it sometimes ends up capturing empty bodies, especially when the websites are built on such modern frontend frameworks as AngularJS, React and Vue.js.

Powered by Headless Chrome, the crawler provides simple APIs to crawl these dynamic websites with the following features:

  • Distributed crawling
  • Configure concurrency, delay and retry
  • Support both depth-first search and breadth-first search algorithm
  • Pluggable cache storages such as Redis
  • Support CSV and JSON Lines for exporting results
  • Pause at the max request and resume at any time
  • Insert jQuery automatically for scraping
  • Save screenshots for the crawling evidence
  • Emulate devices and user agents
  • Priority queue for crawling efficiency
  • Obey robots.txt
  • Follow sitemap.xml
  • [Promise] support

Getting Started

Installation

yarn add headless-chrome-crawler
# or "npm i headless-chrome-crawler"

Note: headless-chrome-crawler contains Puppeteer. During installation, it automatically downloads a recent version of Chromium. To skip the download, see Environment variables.

Usage

const HCCrawler = require('headless-chrome-crawler');

(async () => {
  const crawler = await HCCrawler.launch({
    // Function to be evaluated in browsers
    evaluatePage: (() => ({
      title: $('title').text(),
    })),
    // Function to be called with evaluated results from browsers
    onSuccess: (result => {
      console.log(result);
    }),
  });
  // Queue a request
  await crawler.queue('https://example.com/');
  // Queue multiple requests
  await crawler.queue(['https://example.net/', 'https://example.org/']);
  // Queue a request with custom options
  await crawler.queue({
    url: 'https://example.com/',
    // Emulate a tablet device
    device: 'Nexus 7',
    // Enable screenshot by passing options
    screenshot: {
      path: './tmp/example-com.png'
    },
  });
  await crawler.onIdle(); // Resolved when no queue is left
  await crawler.close(); // Close the crawler
})();

Examples

See here for the full examples list. The examples can be run from the root folder as follows:

NODE_PATH=../ node examples/priority-queue.js

API reference

See here for the API reference.

Debugging tips

See here for the debugging tips.

FAQ

How is this different from other crawlers?

There are roughly two types of crawlers. One is static and the other is dynamic.

The static crawlers are based on simple requests to HTML files. They are generally fast, but fail scraping the contents when the HTML dynamically changes on browsers.

Dynamic crawlers based on PhantomJS and Selenium work magically on such dynamic applications. However, PhantomJS's maintainer has stepped down and recommended to switch to Headless Chrome, which is fast and stable. Selenium is still a well-maintained cross browser platform which runs on Chrome, Safari, IE and so on. However, crawlers do not need such cross browsers support.

This crawler is dynamic and based on Headless Chrome.

How is this different from Puppeteer?

This crawler is built on top of Puppeteer.

Puppeteer provides low to mid level APIs to manupulate Headless Chrome, so you can build your own crawler with it. This way you have more controls on what features to implement in order to satisfy your needs.

However, most crawlers requires such common features as following links, obeying robots.txt and etc. This crawler is a general solution for most crawling purposes. If you want to quickly start crawling with Headless Chrome, this crawler is for you.

Ähnliche Repositories
puppeteer/puppeteer

JavaScript API for Chrome and Firefox

TypeScriptnpmApache License 2.0headless-chrometesting
pptr.dev
95.3k9.5k
apify/crawlee

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

TypeScriptnpmApache License 2.0web-scrapingweb-crawling
crawlee.dev
24.8k1.6k
segment-boneyard/nightmare

A high-level browser automation library.

JavaScriptnpmelectronheadless-chrome
open.segment.com
19.8k1.1k
schickling/chromeless

🖥 Chrome automation made simple. Runs locally or headless on AWS Lambda.

TypeScriptnpmMIT Licenseserverlessintegration-testing
chromeless.netlify.com
13.2k569
pinchtab/pinchtab

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

GoGo ModulesMIT Licensebrowser-automationcdp
9.4k702
apify/crawlee-python

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.

PythonPyPIApache License 2.0apifyautomation
crawlee.dev/python/
9.3k778
berstend/puppeteer-extra

💯 Teach puppeteer new tricks through plugins.

JavaScriptnpmMIT Licensepuppeteerchrome
extra.community
7.4k780
alvarcarto/url-to-pdf-api

Web page PDF/PNG rendering done right. Self-hosted service for rendering receipts, invoices, or any content.

HTMLMIT Licensepdfchrome
7.1k778
GoogleChrome/rendertron

A Headless Chrome rendering solution

TypeScriptnpmApache License 2.0renderingheadless-chrome
render-tron.appspot.com
6k901
getgauge/taiko

A node.js library for testing modern web applications

JavaScriptnpmMIT Licensetesting-toolsheadless
taiko.dev
3.7k460
miyakogi/pyppeteer

Headless chrome/chromium automation library (unofficial port of puppeteer)

PythonPyPIOtherheadless-chromebrowser-automation
3.6k369
thomasdondorf/puppeteer-cluster

Puppeteer Pool, run a cluster of instances in parallel

TypeScriptnpmMIT Licensepuppeteerpool
3.5k318