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.
TypeScript apifyautomationcrawlercrawlingheadlessheadless-chromejavascriptnodejsnpmplaywrightpuppeteerscraperscrapingtypescriptweb-crawlerweb-crawlingweb-scraping
Updated docs and README
Jan Curn3f8adb07a9e6
diff --git a/README.md b/README.mdindex a13efae37..e78923d13 100644--- a/README.md+++ b/README.md@@ -200,7 +200,7 @@ The following table shows the basic environment variables used by Apify SDK:<tr><td><code>APIFY_TOKEN</code></td><td>- The API token for your Apify account. It is used to access the Apify API, e.g. to access cloud storage or to run an actor in the cloud.+ The API token for your Apify Account. It is used to access the Apify API, e.g. to access cloud storage or to run an actor in the cloud.You can find your API token on the <a href="https://my.apify.com/account#intergrations">Account - Integrations</a> page.If omitted, you should define the <code>APIFY_LOCAL_STORAGE_DIR</code> environment variable instead.</td>@@ -209,7 +209,7 @@ The following table shows the basic environment variables used by Apify SDK:<td><code>APIFY_PROXY_PASSWORD</code></td><td>Optional password to <a href="https://www.apify.com/docs/proxy" target="_blank">Apify Proxy</a> for IP address rotation.- If you have have an Apify account, you can find the password on the+ If you have have an Apify Account, you can find the password on the<a href="https://my.apify.com/proxy" target="_blank">Proxy page</a> in the Apify app.This feature is optional. You can use your own proxies or no proxies at all.</td>@@ -271,7 +271,7 @@ and [Apify Actor](https://www.apify.com/docs/actor) documentation.### Usage on the Apify cloud platformYou can also develop your web scraping project-in an online code editor directly on the Apify cloud. You'll need to have an Apify account.+in an online code editor directly on the Apify cloud. You'll need to have an Apify Account.Go to [Actors](https://my.apify.com/actors)page in the app, click <i>Create new</i> and then go to the<i>Source</i> tab and start writing your code or paste one of the code examples below.@@ -286,7 +286,7 @@ It can run for a few seconds, hours or even infinitely.An actor can perform anything from a simple action such as filling out a web form or sending an email,to complex operations such as crawling an entire website and removing duplicates from a large dataset.-To run an actor, you need to have an [Apify account](https://my.apify.com/).+To run an actor, you need to have an [Apify Account](https://my.apify.com/).The actor execution is charged towards your account and the cost depends onthe amount of memory allocated for the run and its duration.Actors can be shared in the [Apify Library](https://www.apify.com/library?&type=acts)@@ -672,7 +672,7 @@ and how to call Apify API usingThe script extracts the current Bitcoin prices from Kraken.comand sends them to your email using the [apify/send-mail](https://www.apify.com/apify/send-mail) actor.-To make the example work, you'll need an [Apify account](https://my.apify.com/).+To make the example work, you'll need an [Apify Account](https://my.apify.com/).Go to [Account - Integrations](https://my.apify.com/account#/integrations) page to obtain your API tokenand set it to the `APIFY_TOKEN` environment variable, or run the script using the CLI.If you deploy this actor to the Apify platform then you can set up a scheduler for earlydiff --git a/src/autoscaling/autoscaled_pool.js b/src/autoscaling/autoscaled_pool.jsindex b40cb9b7f..13851568a 100644--- a/src/autoscaling/autoscaled_pool.js+++ b/src/autoscaling/autoscaled_pool.js@@ -26,20 +26,23 @@ const DEFAULT_OPTIONS = {* or from the Apify cloud infrastructure in case the process is running on the Apify platform.* Meaningful data gathered from these snapshots is provided to `AutoscaledPool` by the `SystemStatus` class.*- * Before running the pool, one must implement three functions. `runTaskFunction()`,- * `isTaskReadyFunction()` and `isFinishedFunction()`.+ * Before running the pool, you need to implement the following three functions:+ * {@link AutoscaledPool#runTaskFunction|`runTaskFunction()`},+ * {@link AutoscaledPool#isTaskReadyFunction|`isTaskReadyFunction()`} and+ * {@link AutoscaledPool#isFinishedFunction|`isFinishedFunction()`}.*- * The auto-scaled pool is started by calling the `run()` function. It queries the `isTaskReadyFunction()`+ * The auto-scaled pool is started by calling the {@link AutoscaledPool#run|`run()`} function.+ * The pool periodically queries the `isTaskReadyFunction()` function* for more tasks, managing optimal concurrency, until the function resolves to `false`. The pool then queries- * the `isFinishedFunction()`. If it resolves to `true`, the pool finishes. If it resolves to `false`, it assumes+ * the `isFinishedFunction()`. If it resolves to `true`, the run finishes. If it resolves to `false`, it assumes* there will be more tasks available later and keeps querying for tasks, until finally both the- * `isTaskReadyFunction()` and `isFinishedFunction()` resolve to `true`. If any of the tasks throws- * then the `run()` function also throws.+ * `isTaskReadyFunction()` and `isFinishedFunction()` functions resolve to `true`. If any of the tasks throws+ * then the `run()` function rejects the promise with an error.** The pool evaluates whether it should start a new task every time one of the tasks finishes* and also in the interval set by the `options.maybeRunIntervalSecs` parameter.*- * Basic usage of `AutoscaledPool`:+ * Example usage:** ```javascript* const pool = new Apify.AutoscaledPool({@@ -100,13 +103,13 @@ const DEFAULT_OPTIONS = {* We suggest using a value from 5 to 20.* @param {Number} [options.snapshotterOptions]* Options to be passed down to the `Snapshotter` constructor. This is useful for fine-tuning- * the snapshot intervals and history. See the <a href="#Snapshotter">Snapshotter documentation</a>- * for available options.+ * the snapshot intervals and history.+ * See <a href="https://github.com/apifytech/apify-js/blob/develop/src/autoscaling/snapshotter.js">Snapshotter</a> source code for more details.* @param {Number} [options.systemStatusOptions]* Options to be passed down to the `SystemStatus` constructor. This is useful for fine-tuning- * the system status reports. See the <a href="#SystemStatus">SystemStatus documentation</a>- * for available options. If a custom snapshotter is set in the options, it will be used+ * the system status reports. If a custom snapshotter is set in the options, it will be used* by the pool.+ * See <a href="https://github.com/apifytech/apify-js/blob/develop/src/autoscaling/system_status.js">SystemStatus</a> source code for more details.*/export default class AutoscaledPool {constructor(options = {}) {diff --git a/src/autoscaling/snapshotter.js b/src/autoscaling/snapshotter.jsindex c4daafb9b..8aab6fc18 100644--- a/src/autoscaling/snapshotter.js+++ b/src/autoscaling/snapshotter.js@@ -18,6 +18,7 @@ const DEFAULT_OPTIONS = {* Creates snapshots of system resources at given intervals and marks the resource* as either overloaded or not during the last interval. Keeps a history of the snapshots.* It tracks the following resources: Memory, EventLoop and CPU.+ * The class is used by the {@linkcode AutoscaledPool} class.** There are differences in behavior when running locally and on the Apify platform,* but those differences are handled internally by the class and do not affect its interface.@@ -27,7 +28,7 @@ const DEFAULT_OPTIONS = {* the Apify platform and a quarter of total system memory when running locally.* Use of total memory may be overridden by using the `maxBlockedRatio` option.*- * Event Loop becomes overloaded if it slows down by more than the `maxBlockedMillis` option.+ * Event loop becomes overloaded if it slows down by more than the `maxBlockedMillis` option.** CPU tracking is available only on the Apify platform and the CPU overloaded event is read* directly off the container and is not configurable.diff --git a/src/autoscaling/system_status.js b/src/autoscaling/system_status.jsindex 0f167fcb9..85f23f123 100644--- a/src/autoscaling/system_status.js+++ b/src/autoscaling/system_status.js@@ -17,6 +17,7 @@ const DEFAULT_OPTIONS = {* messages in the snapshots, with the weights being the time intervals* between the snapshots. Each resource is calculated separately* and the system is overloaded whenever at least one resource is overloaded.+ * The class is used by the {@linkcode AutoscaledPool} class.** `getCurrentStatus()` returns a boolean that represents the current status of the system.* The length of the current timeframe in seconds is configurable