@crawlee/browser 3.17.1-beta.7 → 3.17.1-beta.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.mjs +3 -0
- package/internals/browser-crawler.d.ts +5 -0
- package/internals/browser-crawler.js +12 -3
- package/package.json +7 -7
package/index.mjs
CHANGED
|
@@ -50,6 +50,7 @@ export const RequestQueue = mod.RequestQueue;
|
|
|
50
50
|
export const RequestQueueV1 = mod.RequestQueueV1;
|
|
51
51
|
export const RequestQueueV2 = mod.RequestQueueV2;
|
|
52
52
|
export const RequestState = mod.RequestState;
|
|
53
|
+
export const RequestValidationError = mod.RequestValidationError;
|
|
53
54
|
export const RetryRequestError = mod.RetryRequestError;
|
|
54
55
|
export const Router = mod.Router;
|
|
55
56
|
export const STATE_PERSISTENCE_KEY = mod.STATE_PERSISTENCE_KEY;
|
|
@@ -79,6 +80,7 @@ export const createDeserialize = mod.createDeserialize;
|
|
|
79
80
|
export const createEventLoopLoadSignal = mod.createEventLoopLoadSignal;
|
|
80
81
|
export const createRequestOptions = mod.createRequestOptions;
|
|
81
82
|
export const createRequests = mod.createRequests;
|
|
83
|
+
export const defaultRoute = mod.defaultRoute;
|
|
82
84
|
export const deserializeArray = mod.deserializeArray;
|
|
83
85
|
export const enqueueLinks = mod.enqueueLinks;
|
|
84
86
|
export const evaluateLoadSignalSample = mod.evaluateLoadSignalSample;
|
|
@@ -100,5 +102,6 @@ export const tryAbsoluteURL = mod.tryAbsoluteURL;
|
|
|
100
102
|
export const updateEnqueueLinksPatternCache = mod.updateEnqueueLinksPatternCache;
|
|
101
103
|
export const useState = mod.useState;
|
|
102
104
|
export const validateGlobPattern = mod.validateGlobPattern;
|
|
105
|
+
export const validateUserData = mod.validateUserData;
|
|
103
106
|
export const validators = mod.validators;
|
|
104
107
|
export const withCheckedStorageAccess = mod.withCheckedStorageAccess;
|
|
@@ -331,6 +331,11 @@ export declare abstract class BrowserCrawler<InternalBrowserPoolOptions extends
|
|
|
331
331
|
protected _cleanupContext(crawlingContext: Context): Promise<void>;
|
|
332
332
|
private containsSelectors;
|
|
333
333
|
protected isRequestBlocked(crawlingContext: Context): Promise<string | false>;
|
|
334
|
+
/**
|
|
335
|
+
* `BrowserCrawler` hands `BasicCrawler` a wrapper that opens a page before delegating, and keeps the user's
|
|
336
|
+
* own handler in `userProvidedRequestHandler` — so resolve router-aware metadata against that instead.
|
|
337
|
+
*/
|
|
338
|
+
protected get userRequestHandler(): RequestHandler<Context>;
|
|
334
339
|
/**
|
|
335
340
|
* Wrapper around requestHandler that opens and closes pages etc.
|
|
336
341
|
*/
|
|
@@ -9,6 +9,7 @@ const browser_pool_1 = require("@crawlee/browser-pool");
|
|
|
9
9
|
const utils_1 = require("@crawlee/utils");
|
|
10
10
|
const ow_1 = tslib_1.__importDefault(require("ow"));
|
|
11
11
|
const timeout_1 = require("@apify/timeout");
|
|
12
|
+
const PAGE_CLOSE_TIMEOUT_MILLIS = 5000;
|
|
12
13
|
/**
|
|
13
14
|
* Provides a simple framework for parallel crawling of web pages
|
|
14
15
|
* using headless browsers with [Puppeteer](https://github.com/puppeteer/puppeteer)
|
|
@@ -185,7 +186,8 @@ class BrowserCrawler extends basic_1.BasicCrawler {
|
|
|
185
186
|
const { page } = crawlingContext;
|
|
186
187
|
// Page creation may be aborted
|
|
187
188
|
if (page) {
|
|
188
|
-
|
|
189
|
+
// Puppeteer 25+ can hang `page.close()` indefinitely when the page's navigation was aborted, don't let it block the crawler.
|
|
190
|
+
await (0, timeout_1.addTimeoutToPromise)(async () => page.close(), PAGE_CLOSE_TIMEOUT_MILLIS, `page.close() timed out after ${PAGE_CLOSE_TIMEOUT_MILLIS / 1000} seconds`).catch((error) => this.log.debug('Error while closing page', { error }));
|
|
189
191
|
}
|
|
190
192
|
}
|
|
191
193
|
async containsSelectors(page, selectors) {
|
|
@@ -220,6 +222,13 @@ class BrowserCrawler extends basic_1.BasicCrawler {
|
|
|
220
222
|
return `Received blocked status code: ${blockedStatusCode}`;
|
|
221
223
|
return false;
|
|
222
224
|
}
|
|
225
|
+
/**
|
|
226
|
+
* `BrowserCrawler` hands `BasicCrawler` a wrapper that opens a page before delegating, and keeps the user's
|
|
227
|
+
* own handler in `userProvidedRequestHandler` — so resolve router-aware metadata against that instead.
|
|
228
|
+
*/
|
|
229
|
+
get userRequestHandler() {
|
|
230
|
+
return this.userProvidedRequestHandler;
|
|
231
|
+
}
|
|
223
232
|
/**
|
|
224
233
|
* Wrapper around requestHandler that opens and closes pages etc.
|
|
225
234
|
*/
|
|
@@ -475,8 +484,8 @@ async function browserCrawlerEnqueueLinks(options) {
|
|
|
475
484
|
if (containsEnqueueLinks(options)) {
|
|
476
485
|
return options.enqueueLinks({
|
|
477
486
|
urls,
|
|
478
|
-
baseUrl,
|
|
479
487
|
...enqueueLinksOptions,
|
|
488
|
+
baseUrl,
|
|
480
489
|
});
|
|
481
490
|
}
|
|
482
491
|
return (0, basic_1.enqueueLinks)({
|
|
@@ -484,8 +493,8 @@ async function browserCrawlerEnqueueLinks(options) {
|
|
|
484
493
|
robotsTxtFile: options.robotsTxtFile,
|
|
485
494
|
onSkippedRequest: options.onSkippedRequest,
|
|
486
495
|
urls,
|
|
487
|
-
baseUrl,
|
|
488
496
|
...enqueueLinksOptions,
|
|
497
|
+
baseUrl,
|
|
489
498
|
});
|
|
490
499
|
}
|
|
491
500
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crawlee/browser",
|
|
3
|
-
"version": "3.17.1-beta.
|
|
3
|
+
"version": "3.17.1-beta.71",
|
|
4
4
|
"description": "The scalable web crawling and scraping library for JavaScript/Node.js. Enables development of data extraction and web automation jobs (not only) with headless Chrome and Puppeteer.",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16.0.0"
|
|
@@ -53,11 +53,11 @@
|
|
|
53
53
|
"access": "public"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@apify/timeout": "^0.
|
|
57
|
-
"@crawlee/basic": "3.17.1-beta.
|
|
58
|
-
"@crawlee/browser-pool": "3.17.1-beta.
|
|
59
|
-
"@crawlee/types": "3.17.1-beta.
|
|
60
|
-
"@crawlee/utils": "3.17.1-beta.
|
|
56
|
+
"@apify/timeout": "^0.4.0",
|
|
57
|
+
"@crawlee/basic": "3.17.1-beta.71",
|
|
58
|
+
"@crawlee/browser-pool": "3.17.1-beta.71",
|
|
59
|
+
"@crawlee/types": "3.17.1-beta.71",
|
|
60
|
+
"@crawlee/utils": "3.17.1-beta.71",
|
|
61
61
|
"ow": "^0.28.1",
|
|
62
62
|
"tslib": "^2.4.0",
|
|
63
63
|
"type-fest": "^4.0.0"
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "94c4c029140e4068184ad3f03d0a71fd8d6984dc"
|
|
85
85
|
}
|