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 README and docs
Jan Curn221cff4b5e50
diff --git a/README.md b/README.mdindex 0019ed023..b79abd76c 100644--- a/README.md+++ b/README.md@@ -702,7 +702,7 @@ Apify.main(async () => {});```-### Run actor as an API+### Use actor as an APIThis example shows shows a quick actor that has a run time of just a few seconds.It opens a [web page](http://goldengatebridge75.org/news/webcam.html) that contains webcam stream from the Golden Gate@@ -759,6 +759,12 @@ Once the code is ready, you will deploy it to Apify cloud where it will automatiset the `APIFY_TOKEN` environment variable and thuse it will use the cloud storage.No code changes are needed.+**Related links**++* [Cloud storage documentation](https://www.apify.com/docs/storage)+* [View storage in Apify app](https://my.apify.com/storage)+* [API reference](https://www.apify.com/docs/api/v2#/reference/key-value-stores)+### Key-value storeThe key-value store is used for saving and reading data records or files.@@ -790,17 +796,17 @@ data value.The following code demonstrates basic operations of key-value stores:```javascript-// Get INPUT value from the default key-value store+// Get actor input from the default key-value storeconst input = await Apify.getValue('INPUT');-// Write OUTPUT value to the default key-value store.+// Write actor output to the default key-value store.await Apify.setValue('OUTPUT', { myResult: 123 });// Open a named key-value storeconst store = await Apify.openKeyValueStore('some-name');// Write record. JavaScript object is automatically converted to JSON,-// strings and binary buffers are stored as they are.+// strings and binary buffers are stored as they areawait store.setValue('some-key', { foo: 'bar' });// Read record. Note that JSON is automatically parsed to a JavaScript object,@@ -908,10 +914,10 @@ const request1 = await queue.fetchNextRequest();const request2 = await queue.fetchNextRequest();const request3 = await queue.fetchNextRequest();-// Mark some requests them as handled+// Mark a request as handledawait queue.markRequestHandled(request1);-// If processing fails then reclaim the request back to the queue+// If processing fails then reclaim the request back to the queue, so that it's crawled againawait queue.reclaimRequest(request2);```diff --git a/src/dataset.js b/src/dataset.jsindex e59be303f..a300a22ae 100644--- a/src/dataset.js+++ b/src/dataset.js@@ -116,7 +116,10 @@ export const chunkBySize = (items, limitBytes) => {* Example usage:** ```javascript- * // Opens dataset called 'some-name'.+ * // Write a single row to the default dataset+ * await Apify.pushData({ col1: 123, col2: 'val2' });+ *+ * // Open a named dataset* const dataset = await Apify.openDataset('some-name');** // Write a single rowdiff --git a/src/key_value_store.js b/src/key_value_store.jsindex 6fb639e52..a7dc663da 100644--- a/src/key_value_store.js+++ b/src/key_value_store.js@@ -105,19 +105,24 @@ export const maybeStringify = (value, options) => {* Example usage:** ```javascript- * // Opens the default key-value store of the actor run.- * const store = await Apify.openKeyValueStore();+ * // Get actor input from the default key-value store+ * const input = await Apify.getValue('INPUT');+ *+ * // Write actor output to the default key-value store.+ * await Apify.setValue('OUTPUT', { myResult: 123 });*- * // Opens a named key-value store- * const storeWithName = await Apify.openKeyValueStore('some-name');+ * // Open a named key-value store+ * const store = await Apify.openKeyValueStore('some-name');*- * // Write record+ * // Write record. JavaScript object is automatically converted to JSON,+ * // strings and binary buffers are stored as they are* await store.setValue('some-key', { foo: 'bar' });*- * // Read record+ * // Read record. Note that JSON is automatically parsed to a JavaScript object,+ * // text data returned as a string and other data is returned as binary buffer* const value = await store.getValue('some-key');*- * // Delete record+ * // Delete record* await store.delete('some-key');* ```*diff --git a/src/request_queue.js b/src/request_queue.jsindex 1b476e685..c6915c25b 100644--- a/src/request_queue.js+++ b/src/request_queue.js@@ -126,10 +126,10 @@ const getRequestId = (uniqueKey) => {* Example usage:** ```javascript- * // Opens default request queue of the run.+ * // Open the default request queue associated with the actor run* const queue = await Apify.openRequestQueue();*- * // Opens request queue called 'some-name'.+ * // Open a named request queue* const queueWithName = await Apify.openRequestQueue('some-name');** // Enqueue few requests@@ -138,15 +138,15 @@ const getRequestId = (uniqueKey) => {* await queue.addRequest(new Apify.Request({ url: 'http://example.com/foo/bar'}), { forefront: true });** // Get requests from queue- * const request1 = queue.fetchNextRequest();- * const request2 = queue.fetchNextRequest();- * const request3 = queue.fetchNextRequest();+ * const request1 = await queue.fetchNextRequest();+ * const request2 = await queue.fetchNextRequest();+ * const request3 = await queue.fetchNextRequest();*- * // Mark some of them as handled- * queue.markRequestHandled(request1);+ * // Mark a request as handled+ * await queue.markRequestHandled(request1);*- * // If processing fails then reclaim it back to the queue- * queue.reclaimRequest(request2);+ * // If processing fails then reclaim the request back to the queue, so that it's crawled again+ * await queue.reclaimRequest(request2);* ```** @param {String} queueId - ID of the request queue.