@crawlee/playwright 4.0.0-beta.342 → 4.0.0-beta.343
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.
|
@@ -2,6 +2,7 @@ import type { BrowserHook, LoadedRequest, RouterHandler, RouteSchemas, RoutesFro
|
|
|
2
2
|
import type { BasicCrawlerOptions, CrawlingContext, EnqueueLinksOptions, ExtractLinksOptions, GetUserDataFromRequest, RouterRoutes } from '@crawlee/basic';
|
|
3
3
|
import { BasicCrawler } from '@crawlee/basic';
|
|
4
4
|
import { CrawlingRequest } from '@crawlee/browser';
|
|
5
|
+
import type { CheerioCrawlerOptions } from '@crawlee/cheerio';
|
|
5
6
|
import type { AddRequestsBatchedResult, StorageTransactionView } from '@crawlee/core';
|
|
6
7
|
import type { Dictionary, Awaitable } from '@crawlee/types';
|
|
7
8
|
import { type Cheerio, type CheerioAPI } from 'cheerio';
|
|
@@ -109,7 +110,20 @@ export interface AdaptiveResultContext {
|
|
|
109
110
|
/** The request whose handler produced the results. */
|
|
110
111
|
request: CrawlingRequest;
|
|
111
112
|
}
|
|
112
|
-
export interface AdaptivePlaywrightCrawlerOptions<ContextExtension = Dictionary<never>, ExtendedContext extends AdaptivePlaywrightCrawlerContext = AdaptivePlaywrightCrawlerContext & ContextExtension, Routes extends Record<keyof Routes, Dictionary> = Record<string, GetUserDataFromRequest<AdaptivePlaywrightCrawlerContext['request']>>, StatisticStateExtension extends AdaptivePlaywrightCrawlerStatisticState = AdaptivePlaywrightCrawlerStatisticState> extends Omit<BasicCrawlerOptions<AdaptivePlaywrightCrawlerContext, ContextExtension, ExtendedContext, Routes, StatisticStateExtension>, 'preNavigationHooks' | 'postNavigationHooks' | 'contextPipelineBuilder'
|
|
113
|
+
export interface AdaptivePlaywrightCrawlerOptions<ContextExtension = Dictionary<never>, ExtendedContext extends AdaptivePlaywrightCrawlerContext = AdaptivePlaywrightCrawlerContext & ContextExtension, Routes extends Record<keyof Routes, Dictionary> = Record<string, GetUserDataFromRequest<AdaptivePlaywrightCrawlerContext['request']>>, StatisticStateExtension extends AdaptivePlaywrightCrawlerStatisticState = AdaptivePlaywrightCrawlerStatisticState> extends Omit<BasicCrawlerOptions<AdaptivePlaywrightCrawlerContext, ContextExtension, ExtendedContext, Routes, StatisticStateExtension>, 'preNavigationHooks' | 'postNavigationHooks' | 'contextPipelineBuilder'> {
|
|
114
|
+
/**
|
|
115
|
+
* If set to `true`, TLS/SSL certificate errors are ignored in both attempts: see
|
|
116
|
+
* {@link HttpCrawlerOptions.ignoreTlsErrors} for the HTTP-only one, the browser gets Playwright's
|
|
117
|
+
* `ignoreHTTPSErrors` launch option. Can't be combined with `browserOptions.browserPool`,
|
|
118
|
+
* `browserOptions.remoteBrowser` or `browserOptions.launchContext.useIncognitoPages`, which don't use the launch options.
|
|
119
|
+
*
|
|
120
|
+
* @default false
|
|
121
|
+
*/
|
|
122
|
+
ignoreTlsErrors?: boolean;
|
|
123
|
+
/** Options of the HTTP-only attempt, forwarded to its {@link CheerioCrawler}. */
|
|
124
|
+
httpOptions?: Pick<CheerioCrawlerOptions, 'additionalMimeTypes'>;
|
|
125
|
+
/** Options of the browser attempt, forwarded to its {@link PlaywrightCrawler}. */
|
|
126
|
+
browserOptions?: Pick<PlaywrightCrawlerOptions, 'launchContext' | 'headless' | 'browserPool' | 'remoteBrowser' | 'ignoreIframes'>;
|
|
113
127
|
/**
|
|
114
128
|
* Timeout for the navigation phase of each attempt, in seconds, shared by the `preNavigationHooks`, the
|
|
115
129
|
* navigation and the `postNavigationHooks`. Applies to both the HTTP-only and the browser attempt. When not
|
|
@@ -169,7 +169,7 @@ export class AdaptivePlaywrightCrawler extends BasicCrawler {
|
|
|
169
169
|
*/
|
|
170
170
|
#shutDown = false;
|
|
171
171
|
constructor(options = {}) {
|
|
172
|
-
const { requestHandler, renderingTypeDetectionRatio = 0.1, renderingTypePredictor, resultChecker, shouldPropagateError, resultComparator, statistics, requestHandlerTimeoutSecs = 60, errorHandler, failedRequestHandler, preNavigationHooks = [], postNavigationHooks = [], extendContext, transactionalStorage, navigationTimeoutSecs,
|
|
172
|
+
const { requestHandler, renderingTypeDetectionRatio = 0.1, renderingTypePredictor, resultChecker, shouldPropagateError, resultComparator, statistics, requestHandlerTimeoutSecs = 60, errorHandler, failedRequestHandler, preNavigationHooks = [], postNavigationHooks = [], extendContext, transactionalStorage, navigationTimeoutSecs, ignoreTlsErrors = false, httpOptions, browserOptions, ...rest } = options;
|
|
173
173
|
// The user's value is replaced by `false` in the `super` call below — validate it separately,
|
|
174
174
|
// wrapped in an object so the error still names the field.
|
|
175
175
|
parseArgument({ transactionalStorage }, z.object({ transactionalStorage: BasicCrawler.optionsShape.transactionalStorage }), 'AdaptivePlaywrightCrawlerOptions');
|
|
@@ -191,6 +191,11 @@ export class AdaptivePlaywrightCrawler extends BasicCrawler {
|
|
|
191
191
|
'attempts. `transactionalStorage: false` is therefore not supported; a write policy ' +
|
|
192
192
|
'object is accepted and forwarded to the per-attempt transactions.');
|
|
193
193
|
}
|
|
194
|
+
const { browserPool, remoteBrowser, launchContext } = browserOptions ?? {};
|
|
195
|
+
if (ignoreTlsErrors && (browserPool || remoteBrowser || launchContext?.useIncognitoPages)) {
|
|
196
|
+
throw new Error('AdaptivePlaywrightCrawler: `ignoreTlsErrors` cannot be combined with `browserPool`, `remoteBrowser` ' +
|
|
197
|
+
'or `launchContext.useIncognitoPages` - configure the browser to ignore TLS errors yourself.');
|
|
198
|
+
}
|
|
194
199
|
super({
|
|
195
200
|
...rest,
|
|
196
201
|
errorHandler,
|
|
@@ -246,6 +251,8 @@ export class AdaptivePlaywrightCrawler extends BasicCrawler {
|
|
|
246
251
|
// each hook's overrides at runtime regardless of the static type.
|
|
247
252
|
const staticCrawler = new CheerioCrawler({
|
|
248
253
|
...rest,
|
|
254
|
+
...httpOptions,
|
|
255
|
+
ignoreTlsErrors,
|
|
249
256
|
statistics: new Statistics({ persistenceOptions: { enable: false } }),
|
|
250
257
|
preNavigationHooks,
|
|
251
258
|
postNavigationHooks,
|
|
@@ -254,15 +261,18 @@ export class AdaptivePlaywrightCrawler extends BasicCrawler {
|
|
|
254
261
|
});
|
|
255
262
|
const browserCrawler = new PlaywrightCrawler({
|
|
256
263
|
...rest,
|
|
264
|
+
...browserOptions,
|
|
265
|
+
...(ignoreTlsErrors && {
|
|
266
|
+
launchContext: {
|
|
267
|
+
...launchContext,
|
|
268
|
+
launchOptions: { ...launchContext?.launchOptions, ignoreHTTPSErrors: true },
|
|
269
|
+
},
|
|
270
|
+
}),
|
|
257
271
|
statistics: new Statistics({ persistenceOptions: { enable: false } }),
|
|
258
272
|
preNavigationHooks: preNavigationHooks,
|
|
259
273
|
postNavigationHooks: postNavigationHooks,
|
|
260
274
|
extendContext,
|
|
261
275
|
navigationTimeoutSecs,
|
|
262
|
-
launchContext,
|
|
263
|
-
headless,
|
|
264
|
-
browserPool,
|
|
265
|
-
remoteBrowser,
|
|
266
276
|
});
|
|
267
277
|
this.#staticCrawler = staticCrawler;
|
|
268
278
|
this.#browserCrawler = browserCrawler;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crawlee/playwright",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.343",
|
|
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": ">=22.13.0"
|
|
@@ -49,14 +49,14 @@
|
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@apify/datastructures": "^3.0.1",
|
|
51
51
|
"@apify/timeout": "^1.1.0",
|
|
52
|
-
"@crawlee/basic": "4.0.0-beta.
|
|
53
|
-
"@crawlee/browser": "4.0.0-beta.
|
|
54
|
-
"@crawlee/browser-pool": "4.0.0-beta.
|
|
55
|
-
"@crawlee/cheerio": "4.0.0-beta.
|
|
56
|
-
"@crawlee/core": "4.0.0-beta.
|
|
57
|
-
"@crawlee/http-client": "4.0.0-beta.
|
|
58
|
-
"@crawlee/types": "4.0.0-beta.
|
|
59
|
-
"@crawlee/utils": "4.0.0-beta.
|
|
52
|
+
"@crawlee/basic": "4.0.0-beta.343",
|
|
53
|
+
"@crawlee/browser": "4.0.0-beta.343",
|
|
54
|
+
"@crawlee/browser-pool": "4.0.0-beta.343",
|
|
55
|
+
"@crawlee/cheerio": "4.0.0-beta.343",
|
|
56
|
+
"@crawlee/core": "4.0.0-beta.343",
|
|
57
|
+
"@crawlee/http-client": "4.0.0-beta.343",
|
|
58
|
+
"@crawlee/types": "4.0.0-beta.343",
|
|
59
|
+
"@crawlee/utils": "4.0.0-beta.343",
|
|
60
60
|
"cheerio": "^1.2.0",
|
|
61
61
|
"domhandler": "^6.0.1",
|
|
62
62
|
"jquery": "^3.8.0",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "becebadb6e1605a4950ba325fb71d09f80607d3e"
|
|
85
85
|
}
|