Skip to content

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.

Build docs

Ondra Urbanb5352f691317
diff --git a/docs/api/PuppeteerPool.md b/docs/api/PuppeteerPool.md
index ea43a7a3c..b6aec499c 100644
--- a/docs/api/PuppeteerPool.md
+++ b/docs/api/PuppeteerPool.md
@@ -112,6 +112,19 @@ await puppeteerPool.destroy();
<td colspan="3"><p>Options used by <code>Apify.launchPuppeteer()</code> to start new Puppeteer instances.
See <a href="../typedefs/launchpuppeteeroptions"><code>LaunchPuppeteerOptions</code></a>.</p>
</td></tr><tr>
+<td><code>[options.recycleDiskCache]</code></td><td><code>Boolean</code></td><td></td>
+</tr>
+<tr>
+<td colspan="3"><p>Enables recycling of disk cache directories by Chrome instances.
+ When a browser instance is closed, its disk cache directory is not deleted but it&#39;s used by a newly opened browser instance.
+ This is useful to reduce amount of data that needs to be downloaded to speed up crawling and reduce proxy usage.
+ Note that the new browser starts with empty cookies, local storage etc. so this setting doesn&#39;t affect anonymity of your crawler.</p>
+<p> Beware that the disk cache directories can consume a lot of disk space.
+ To limit the space consumed, you can pass the <code>--disk-cache-size=X</code> argument to <code>options.launchPuppeteerOptions.args</code>,
+ where <code>X</code> is the approximate maximum number of bytes for disk cache.</p>
+<p> Do not use the <code>options.recycleDiskCache</code> setting together with <code>--disk-cache-dir</code>
+ argument in <code>options.launchPuppeteerOptions.args</code>, the behavior is undefined.</p>
+</td></tr><tr>
<td><code>[options.proxyUrls]</code></td><td><code>Array&lt;String&gt;</code></td><td></td>
</tr>
<tr>
diff --git a/docs/examples/PuppeteerCrawler.md b/docs/examples/PuppeteerCrawler.md
index c327dc582..23b40fd81 100644
--- a/docs/examples/PuppeteerCrawler.md
+++ b/docs/examples/PuppeteerCrawler.md
@@ -4,8 +4,7 @@ title: Puppeteer Crawler
---
This example demonstrates how to use [`PuppeteerCrawler`](../api/puppeteercrawler)
-in combination with [`RequestList`](../api/requestlist)
-and [`RequestQueue`](../api/requestqueue) to recursively scrape the
+in combination with [`RequestQueue`](../api/requestqueue) to recursively scrape the
<a href="https://news.ycombinator.com" target="_blank">Hacker News website</a> using headless Chrome / Puppeteer.
The crawler starts with a single URL, finds links to next pages,
enqueues them and continues until no more desired links are available.
@@ -17,23 +16,14 @@ on the source tab of your actor configuration.
const Apify = require('apify');
Apify.main(async () => {
- // Create and initialize an instance of the RequestList class that contains the start URL.
- const requestList = new Apify.RequestList({
- sources: [
- { url: 'https://news.ycombinator.com/' },
- ],
- });
- await requestList.initialize();
-
// Apify.openRequestQueue() is a factory to get a preconfigured RequestQueue instance.
+ // We add our first request to it - the initial page the crawler will visit.
const requestQueue = await Apify.openRequestQueue();
+ await requestQueue.addRequest({ url: 'https://news.ycombinator.com/' });
// Create an instance of the PuppeteerCrawler class - a crawler
// that automatically loads the URLs in headless Chrome / Puppeteer.
const crawler = new Apify.PuppeteerCrawler({
- // The crawler will first fetch start URLs from the RequestList
- // and then the newly discovered URLs from the RequestQueue
- requestList,
requestQueue,
// Here you can set options that are passed to the Apify.launchPuppeteer() function.
@@ -85,6 +75,9 @@ Apify.main(async () => {
// This function is called if the page processing failed more than maxRequestRetries+1 times.
handleFailedRequestFunction: async ({ request }) => {
console.log(`Request ${request.url} failed too many times`);
+ await Apify.pushData({
+ '#debug': Apify.utils.createRequestDebugInfo(request),
+ });
},
});