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.

Improve docs, bump package versions

Ondra Urbanad847c7f6266
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 149d71809..d505c3ac8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+0.15.5 / 2019-08-15
+====================
+- This release just updates some dependencies (not Puppeteer).
+
0.15.4 / 2019-08-02
====================
- **DEPRECATED**: `dataset.delete()`, `keyValueStore.delete()` and `requestQueue.delete()` methods have been
diff --git a/docs/api/RequestQueue.md b/docs/api/RequestQueue.md
index 8a42e98cc..b9f71ae8c 100644
--- a/docs/api/RequestQueue.md
+++ b/docs/api/RequestQueue.md
@@ -84,6 +84,9 @@ Adds a request to the queue.
If a request with the same `uniqueKey` property is already present in the queue, it will not be updated. You can find out whether this happened from
the resulting [`QueueOperationInfo`](../typedefs/queueoperationinfo) object.
+To add multiple requests to the queue by extracting links from a webpage, see the [`Apify.utils.enqueueLinks()`](utils#utils.enqueueLinks) helper
+function.
+
<table>
<thead>
<tr>
diff --git a/docs/api/puppeteer.md b/docs/api/puppeteer.md
index cc7410ac3..668b15278 100644
--- a/docs/api/puppeteer.md
+++ b/docs/api/puppeteer.md
@@ -135,10 +135,12 @@ objects.
a combination of <code>url</code>, <code>method</code> and <code>payload</code> which enables crawling of websites that navigate using form submits
(POST requests).</p>
<p> <strong>Example:</strong></p>
-<pre><code class="language-javascript"> function transformRequestFunction(request) {
- request.userData.foo = &#39;bar&#39;;
- request.useExtendedUniqueKey = true;
- return request;
+<pre><code class="language-javascript"> {
+ transformRequestFunction: (request) =&gt; {
+ request.userData.foo = &#39;bar&#39;;
+ request.useExtendedUniqueKey = true;
+ return request;
+ }
}</code></pre>
</td></tr><tr>
<td><code>[options.waitForPageIdleSecs]</code></td><td><code>number</code></td><td><code>1</code></td>
diff --git a/docs/api/utils.md b/docs/api/utils.md
index 0847a43fa..09ef351e4 100644
--- a/docs/api/utils.md
+++ b/docs/api/utils.md
@@ -118,12 +118,21 @@ objects.
<td><code>[options.transformRequestFunction]</code></td><td><code>function</code></td><td></td>
</tr>
<tr>
-<td colspan="3"><p>Just before a new <a href="request"><code>Request</code></a> is constructed and enqueued to the <a href="requestqueue"><code>RequestQueue</code></a>, this function can be used
+<td colspan="3"><p><strong>Signature:</strong> (<a href="request"><code>Request</code></a>): <a href="request"><code>Request</code></a></p>
+<p> Just before a new <a href="request"><code>Request</code></a> is constructed and enqueued to the <a href="requestqueue"><code>RequestQueue</code></a>, this function can be used
to remove it or modify its contents such as <code>userData</code>, <code>payload</code> or, most importantly <code>uniqueKey</code>. This is useful
when you need to enqueue multiple <code>Requests</code> to the queue that share the same URL, but differ in methods or payloads,
or to dynamically update or create <code>userData</code>.</p>
<p> For example: by adding <code>keepUrlFragment: true</code> to the <code>request</code> object, URL fragments will not be removed
when <code>uniqueKey</code> is computed.</p>
+<p> <strong>Example:</strong></p>
+<pre><code class="language-javascript"> {
+ transformRequestFunction: (request) =&gt; {
+ request.userData.foo = &#39;bar&#39;;
+ request.keepUrlFragment = true;
+ return request;
+ }
+ }</code></pre>
</td></tr></tbody>
</table>
<a name="utils.requestAsBrowser"></a>
diff --git a/package.json b/package.json
index 0683fe569..d4681a2f6 100644
--- a/package.json
+++ b/package.json
@@ -49,11 +49,11 @@
"lint:fix": "./node_modules/.bin/eslint ./src ./test --ext .js,.jsx --fix"
},
"dependencies": {
- "@apify/http-request": "^1.0.5",
+ "@apify/http-request": "^1.0.6",
"@apify/ps-tree": "^1.1.3",
- "apify-client": "^0.5.24",
- "apify-shared": "^0.1.55",
- "cheerio": "^1.0.0-rc.2",
+ "apify-client": "^0.5.25",
+ "apify-shared": "^0.1.56",
+ "cheerio": "^1.0.0-rc.3",
"content-type": "^1.0.4",
"express": "^4.17.1",
"fs-extra": "^8.1.0",
diff --git a/src/enqueue_links/click_elements.js b/src/enqueue_links/click_elements.js
index 01cc78f29..3451c1f7e 100644
--- a/src/enqueue_links/click_elements.js
+++ b/src/enqueue_links/click_elements.js
@@ -87,10 +87,12 @@ const STARTING_Z_INDEX = 2147400000;
*
* **Example:**
* ```javascript
- * function transformRequestFunction(request) {
- * request.userData.foo = 'bar';
- * request.useExtendedUniqueKey = true;
- * return request;
+ * {
+ * transformRequestFunction: (request) => {
+ * request.userData.foo = 'bar';
+ * request.useExtendedUniqueKey = true;
+ * return request;
+ * }
* }
* ```
* @param {number} [options.waitForPageIdleSecs=1]
diff --git a/src/enqueue_links/enqueue_links.js b/src/enqueue_links/enqueue_links.js
index a5f457642..fec56dc3d 100644
--- a/src/enqueue_links/enqueue_links.js
+++ b/src/enqueue_links/enqueue_links.js
@@ -63,6 +63,8 @@ import { constructPseudoUrlInstances, createRequests, addRequestsToQueueInBatche
* If `pseudoUrls` is an empty array, `null` or `undefined`, then the function
* enqueues all links found on the page.
* @param {Function} [options.transformRequestFunction]
+ * **Signature:** ({@link Request}): {@link Request}
+ *
* Just before a new {@link Request} is constructed and enqueued to the {@link RequestQueue}, this function can be used
* to remove it or modify its contents such as `userData`, `payload` or, most importantly `uniqueKey`. This is useful
* when you need to enqueue multiple `Requests` to the queue that share the same URL, but differ in methods or payloads,
@@ -70,6 +72,17 @@ import { constructPseudoUrlInstances, createRequests, addRequestsToQueueInBatche
*
* For example: by adding `keepUrlFragment: true` to the `request` object, URL fragments will not be removed
* when `uniqueKey` is computed.
+ *
+ * **Example:**
+ * ```javascript
+ * {
+ * transformRequestFunction: (request) => {
+ * request.userData.foo = 'bar';
+ * request.keepUrlFragment = true;
+ * return request;
+ * }
+ * }
+ * ```
* @return {Promise<QueueOperationInfo[]>}
* Promise that resolves to an array of {@link QueueOperationInfo} objects.
* @memberOf utils
diff --git a/src/request_queue.js b/src/request_queue.js
index 66ba2fd0c..397a0fa77 100644
--- a/src/request_queue.js
+++ b/src/request_queue.js
@@ -247,6 +247,9 @@ export class RequestQueue {
* it will not be updated. You can find out whether this happened from the resulting
* {@link QueueOperationInfo} object.
*
+ * To add multiple requests to the queue by extracting links from a webpage,
+ * see the [`Apify.utils.enqueueLinks()`](utils#utils.enqueueLinks) helper function.
+ *
* @param {Request|Object} request {@link Request} object or vanilla object with request data.
* Note that the function sets the `uniqueKey` and `id` fields to the passed object.
* @param {Object} [options]