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.

Update docs

Ondra Urbanf70a3599f904
diff --git a/src/autoscaling/autoscaled_pool.js b/src/autoscaling/autoscaled_pool.js
index 43d382487..620513cdb 100644
--- a/src/autoscaling/autoscaled_pool.js
+++ b/src/autoscaling/autoscaled_pool.js
@@ -228,7 +228,15 @@ class AutoscaledPool {
}
/**
- * Aborts the run of the auto-scaled pool, discards all currently running tasks and destroys it.
+ * Aborts the run of the auto-scaled pool and destroys it. The promise returned from
+ * the [`run()`](#AutoscaledPool+run) function will immediately resolve, no more new tasks
+ * will be spawned and all running tasks will be left in their current state.
+ *
+ * Due to the nature of the tasks, auto-scaled pool cannot reliably guarantee abortion
+ * of all the running tasks, therefore, no abortion is attempted and some of the tasks
+ * may finish, while others may not. Essentially, auto-scaled pool doesn't care about
+ * their state after the invocation of `.abort()`, but that does not mean that some
+ * parts of their asynchronous chains of commands will not execute.
*
* @return {Promise}
*/
@@ -247,6 +255,10 @@ class AutoscaledPool {
* The function's promise will resolve once all running tasks have completed and the pool
* is effectively idle. If the `timeoutSecs` argument is provided, the promise will reject
* with a timeout error after the `timeoutSecs` seconds.
+ *
+ * The promise returned from the [`run()`](#AutoscaledPool+run) function will not resolve
+ * when `.pause()` is invoked (unlike abort, which resolves it).
+ *
* @param {number} [timeoutSecs]
* @return {Promise}
*/
diff --git a/src/basic_crawler.js b/src/basic_crawler.js
index 5e7451863..6a0e71b24 100644
--- a/src/basic_crawler.js
+++ b/src/basic_crawler.js
@@ -91,7 +91,8 @@ const DEFAULT_OPTIONS = {
* The function receives the following object as an argument:
* ```
* {
- * request: Request
+ * request: Request,
+ * autoscaledPool: AutoscaledPool
* }
* ```
* where the {@link Request} instance represents the URL to crawl.
diff --git a/src/cheerio_crawler.js b/src/cheerio_crawler.js
index da7a0eae9..2e7977ee4 100644
--- a/src/cheerio_crawler.js
+++ b/src/cheerio_crawler.js
@@ -107,7 +107,8 @@ const DEFAULT_OPTIONS = {
* $: Cheerio, // the Cheerio object with parsed HTML
* html: String // the raw HTML of the page
* request: Request,
- * response: Object // An instance of Node's http.IncomingMessage object
+ * response: Object // An instance of Node's http.IncomingMessage object,
+ * autoscaledPool: AutoscaledPool
* }
* ```
* With the {@link Request} object representing the URL to crawl.
@@ -189,7 +190,9 @@ const DEFAULT_OPTIONS = {
* @param {Object} [options.autoscaledPoolOptions]
* Custom options passed to the underlying {@link AutoscaledPool} constructor.
* Note that the `runTaskFunction`, `isTaskReadyFunction` and `isFinishedFunction` options
- * are provided by `CheerioCrawler` and cannot be overridden.
+ * are provided by `CheerioCrawler` and cannot be overridden. Reasonable {@link Snapshotter}
+ * and {@link SystemStatus} defaults are provided to account for the fact that `cheerio`
+ * parses HTML synchronously and therefore blocks the event loop.
* @param {Object} [options.minConcurrency=1]
* Sets the minimum concurrency (parallelism) for the crawl. Shortcut to the corresponding {@link AutoscaledPool} option.
*
diff --git a/src/puppeteer_crawler.js b/src/puppeteer_crawler.js
index bf278a4c2..2d8445391 100644
--- a/src/puppeteer_crawler.js
+++ b/src/puppeteer_crawler.js
@@ -82,7 +82,8 @@ const PAGE_CLOSE_TIMEOUT_MILLIS = 30000;
* request: Request,
* response: Response,
* page: Page,
- * puppeteerPool: PuppeteerPool
+ * puppeteerPool: PuppeteerPool,
+ * autoscaledPool: AutoscaledPool
* }
* ```
*