{"id":13393340,"url":"https://github.com/yujiosaka/headless-chrome-crawler","last_synced_at":"2025-05-14T02:06:45.981Z","repository":{"id":37734845,"uuid":"112821105","full_name":"yujiosaka/headless-chrome-crawler","owner":"yujiosaka","description":"Distributed crawler powered by Headless Chrome","archived":false,"fork":false,"pushed_at":"2023-04-29T20:48:51.000Z","size":1607,"stargazers_count":5562,"open_issues_count":33,"forks_count":408,"subscribers_count":115,"default_branch":"master","last_synced_at":"2025-04-10T16:48:43.615Z","etag":null,"topics":["chrome","chromium","crawler","crawling","headless-chrome","jquery","promise","puppeteer","scraper","scraping"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yujiosaka.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"docs/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-12-02T07:12:12.000Z","updated_at":"2025-04-09T09:29:56.000Z","dependencies_parsed_at":"2022-09-17T11:00:17.428Z","dependency_job_id":"e5d90696-156d-49ab-880c-dbff498d12bf","html_url":"https://github.com/yujiosaka/headless-chrome-crawler","commit_stats":{"total_commits":446,"total_committers":9,"mean_commits":49.55555555555556,"dds":0.3363228699551569,"last_synced_commit":"f4004f6f1a27534222703f9161f44815c8eefbe3"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yujiosaka%2Fheadless-chrome-crawler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yujiosaka%2Fheadless-chrome-crawler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yujiosaka%2Fheadless-chrome-crawler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yujiosaka%2Fheadless-chrome-crawler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yujiosaka","download_url":"https://codeload.github.com/yujiosaka/headless-chrome-crawler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254052713,"owners_count":22006716,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chrome","chromium","crawler","crawling","headless-chrome","jquery","promise","puppeteer","scraper","scraping"],"created_at":"2024-07-30T17:00:50.645Z","updated_at":"2025-05-14T02:06:40.970Z","avatar_url":"https://github.com/yujiosaka.png","language":"JavaScript","funding_links":[],"categories":["Opensource projects","JavaScript","All","Repository","📦 Legacy \u0026 Inactive Projects","chromium","渲染和网页抓取","Rendering and web scraping","JS/ES6"],"sub_categories":["Crawler","贡献"],"readme":"# Headless Chrome Crawler [![npm](https://badge.fury.io/js/headless-chrome-crawler.svg)](https://www.npmjs.com/package/headless-chrome-crawler) [![build](https://circleci.com/gh/yujiosaka/headless-chrome-crawler/tree/master.svg?style=shield\u0026circle-token=ba45f930aed7057b79f2ac09df6be3e1b8ee954b)](https://circleci.com/gh/yujiosaka/headless-chrome-crawler/tree/master) [![Greenkeeper badge](https://badges.greenkeeper.io/yujiosaka/headless-chrome-crawler.svg)](https://greenkeeper.io/)\n\n###### [API](https://github.com/yujiosaka/headless-chrome-crawler/blob/master/docs/API.md) | [Examples](https://github.com/yujiosaka/headless-chrome-crawler/tree/master/examples) | [Tips](https://github.com/yujiosaka/headless-chrome-crawler/blob/master/docs/TIPS.md) | [Code of Conduct](https://github.com/yujiosaka/headless-chrome-crawler/blob/master/docs/CODE_OF_CONDUCT.md) | [Contributing](https://github.com/yujiosaka/headless-chrome-crawler/blob/master/docs/CONTRIBUTING.md) | [Changelog](https://github.com/yujiosaka/headless-chrome-crawler/blob/master/docs/CHANGELOG.md)\n\nDistributed crawler powered by Headless Chrome\n\n\u003cimg src=\"https://user-images.githubusercontent.com/2261067/36531211-81d54840-1800-11e8-8aa7-019c777712bf.png\" height=\"300\" align=\"right\"\u003e\n\n## Features\n\nCrawlers 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](https://angularjs.org), [React](https://reactjs.org) and [Vue.js](https://jp.vuejs.org/index.html).\n\nPowered by Headless Chrome, the crawler provides [simple APIs](#api-reference) to crawl these dynamic websites with the following features:\n\n* Distributed crawling\n* Configure concurrency, delay and retry\n* Support both [depth-first search](https://en.wikipedia.org/wiki/Depth-first_search) and [breadth-first search](https://en.wikipedia.org/wiki/Breadth-first_search) algorithm\n* Pluggable cache storages such as [Redis](https://redis.io)\n* Support [CSV](https://tools.ietf.org/html/rfc4180) and [JSON Lines](http://jsonlines.org) for exporting results\n* Pause at the max request and resume at any time\n* Insert [jQuery](https://jquery.com) automatically for scraping\n* Save screenshots for the crawling evidence\n* Emulate devices and user agents\n* Priority queue for crawling efficiency\n* Obey [robots.txt](https://developers.google.com/search/reference/robots_txt)\n* Follow [sitemap.xml](https://www.sitemaps.org/)\n* [Promise] support\n\n## Getting Started\n\n### Installation\n\n```sh\nyarn add headless-chrome-crawler\n# or \"npm i headless-chrome-crawler\"\n```\n\n\u003e **Note**: headless-chrome-crawler contains [Puppeteer](https://github.com/GoogleChrome/puppeteer). During installation, it automatically downloads a recent version of Chromium. To skip the download, see [Environment variables](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#environment-variables).\n\n### Usage\n\n```js\nconst HCCrawler = require('headless-chrome-crawler');\n\n(async () =\u003e {\n  const crawler = await HCCrawler.launch({\n    // Function to be evaluated in browsers\n    evaluatePage: (() =\u003e ({\n      title: $('title').text(),\n    })),\n    // Function to be called with evaluated results from browsers\n    onSuccess: (result =\u003e {\n      console.log(result);\n    }),\n  });\n  // Queue a request\n  await crawler.queue('https://example.com/');\n  // Queue multiple requests\n  await crawler.queue(['https://example.net/', 'https://example.org/']);\n  // Queue a request with custom options\n  await crawler.queue({\n    url: 'https://example.com/',\n    // Emulate a tablet device\n    device: 'Nexus 7',\n    // Enable screenshot by passing options\n    screenshot: {\n      path: './tmp/example-com.png'\n    },\n  });\n  await crawler.onIdle(); // Resolved when no queue is left\n  await crawler.close(); // Close the crawler\n})();\n```\n\n## Examples\n\n* [Priority queue for crawling efficiency](https://github.com/yujiosaka/headless-chrome-crawler/blob/master/examples/priority-queue.js)\n* [Emulate device and user agent](https://github.com/yujiosaka/headless-chrome-crawler/blob/master/examples/emulate-device.js)\n* [Redis cache to skip duplicate requests](https://github.com/yujiosaka/headless-chrome-crawler/blob/master/examples/redis-cache.js)\n* [Export a CSV file for crawled results](https://github.com/yujiosaka/headless-chrome-crawler/blob/master/examples/csv-exporter.js)\n* [Conditionally saving screenshots](https://github.com/yujiosaka/headless-chrome-crawler/blob/master/examples/conditional-screenshot.js)\n\nSee [here](https://github.com/yujiosaka/headless-chrome-crawler/tree/master/examples) for the full examples list. The examples can be run from the root folder as follows:\n\n```sh\nNODE_PATH=../ node examples/priority-queue.js\n```\n\n## API reference\n\nSee [here](https://github.com/yujiosaka/headless-chrome-crawler/blob/master/docs/API.md) for the API reference.\n\n## Debugging tips\n\nSee [here](https://github.com/yujiosaka/headless-chrome-crawler/blob/master/docs/TIPS.md) for the debugging tips.\n\n## FAQ\n\n### How is this different from other crawlers?\n\nThere are roughly two types of crawlers. One is static and the other is dynamic.\n\nThe 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.\n\nDynamic crawlers based on [PhantomJS](http://phantomjs.org) and [Selenium](http://www.seleniumhq.org) work magically on such dynamic applications. However, [PhantomJS's maintainer has stepped down and recommended to switch to Headless Chrome](https://groups.google.com/forum/#!topic/phantomjs/9aI5d-LDuNE), which is fast and stable. [Selenium](http://www.seleniumhq.org) 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.\n\nThis crawler is dynamic and based on Headless Chrome.\n\n### How is this different from Puppeteer?\n\nThis crawler is built on top of [Puppeteer](https://github.com/GoogleChrome/puppeteer).\n\n[Puppeteer](https://github.com/GoogleChrome/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.\n\nHowever, most crawlers requires such common features as following links, obeying [robots.txt](https://developers.google.com/search/reference/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.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyujiosaka%2Fheadless-chrome-crawler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyujiosaka%2Fheadless-chrome-crawler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyujiosaka%2Fheadless-chrome-crawler/lists"}