@crawlee/playwright 4.0.0-beta.102 → 4.0.0-beta.103
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.
|
@@ -186,7 +186,7 @@ export declare class AdaptivePlaywrightCrawler<ContextExtension = Dictionary<nev
|
|
|
186
186
|
private staticContextPipeline;
|
|
187
187
|
private browserContextPipeline;
|
|
188
188
|
private individualRequestHandlerTimeoutMillis;
|
|
189
|
-
|
|
189
|
+
get stats(): AdaptivePlaywrightCrawlerStatistics;
|
|
190
190
|
private resultObjects;
|
|
191
191
|
private inFlightRenderingTypeDetections;
|
|
192
192
|
private teardownHooks;
|
|
@@ -90,17 +90,30 @@ export class AdaptivePlaywrightCrawler extends BasicCrawler {
|
|
|
90
90
|
staticContextPipeline;
|
|
91
91
|
browserContextPipeline;
|
|
92
92
|
individualRequestHandlerTimeoutMillis;
|
|
93
|
+
// The constructor always injects an `AdaptivePlaywrightCrawlerStatistics`, so narrowing the cast is sound.
|
|
94
|
+
get stats() {
|
|
95
|
+
return super.stats;
|
|
96
|
+
}
|
|
93
97
|
resultObjects = new WeakMap();
|
|
94
98
|
inFlightRenderingTypeDetections = 0;
|
|
95
99
|
teardownHooks = [];
|
|
96
100
|
constructor(options = {}) {
|
|
97
|
-
const { requestHandler, renderingTypeDetectionRatio = 0.1, renderingTypePredictor, resultChecker, shouldPropagateError, resultComparator,
|
|
101
|
+
const { requestHandler, renderingTypeDetectionRatio = 0.1, renderingTypePredictor, resultChecker, shouldPropagateError, resultComparator, statistics, preventDirectStorageAccess = true, requestHandlerTimeoutSecs = 60, errorHandler, failedRequestHandler, preNavigationHooks = [], postNavigationHooks = [], extendContext, contextPipelineBuilder, ...rest } = options;
|
|
102
|
+
if (statistics !== undefined && !(statistics instanceof AdaptivePlaywrightCrawlerStatistics)) {
|
|
103
|
+
throw new Error('AdaptivePlaywrightCrawler tracks extra fields on its own Statistics subclass and cannot use a ' +
|
|
104
|
+
'plain `statistics` instance. Omit the option to let the crawler build its own.');
|
|
105
|
+
}
|
|
98
106
|
super({
|
|
99
107
|
...rest,
|
|
100
108
|
errorHandler,
|
|
101
109
|
failedRequestHandler,
|
|
102
110
|
requestHandler,
|
|
103
111
|
requestHandlerTimeoutSecs,
|
|
112
|
+
// Inject our subclass so the base tracks the extra adaptive fields instead of building a plain `Statistics`.
|
|
113
|
+
statistics: statistics ??
|
|
114
|
+
new AdaptivePlaywrightCrawlerStatistics({
|
|
115
|
+
logMessage: `${AdaptivePlaywrightCrawler.name} request statistics:`,
|
|
116
|
+
}),
|
|
104
117
|
contextPipelineBuilder: contextPipelineBuilder ?? (() => this.buildContextPipeline()),
|
|
105
118
|
});
|
|
106
119
|
this.individualRequestHandlerTimeoutMillis = requestHandlerTimeoutSecs * 1000;
|
|
@@ -134,18 +147,14 @@ export class AdaptivePlaywrightCrawler extends BasicCrawler {
|
|
|
134
147
|
// each hook's overrides at runtime regardless of the static type.
|
|
135
148
|
const staticCrawler = new CheerioCrawler({
|
|
136
149
|
...rest,
|
|
137
|
-
|
|
138
|
-
persistenceOptions: { enable: false },
|
|
139
|
-
},
|
|
150
|
+
statistics: new Statistics({ persistenceOptions: { enable: false } }),
|
|
140
151
|
preNavigationHooks,
|
|
141
152
|
postNavigationHooks,
|
|
142
153
|
extendContext,
|
|
143
154
|
});
|
|
144
155
|
const browserCrawler = new PlaywrightCrawler({
|
|
145
156
|
...rest,
|
|
146
|
-
|
|
147
|
-
persistenceOptions: { enable: false },
|
|
148
|
-
},
|
|
157
|
+
statistics: new Statistics({ persistenceOptions: { enable: false } }),
|
|
149
158
|
preNavigationHooks: preNavigationHooks,
|
|
150
159
|
postNavigationHooks: postNavigationHooks,
|
|
151
160
|
extendContext,
|
|
@@ -157,10 +166,6 @@ export class AdaptivePlaywrightCrawler extends BasicCrawler {
|
|
|
157
166
|
this.browserContextPipeline = browserCrawler.contextPipeline.compose({
|
|
158
167
|
action: this.adaptPlaywrightContext.bind(this),
|
|
159
168
|
});
|
|
160
|
-
this.stats = new AdaptivePlaywrightCrawlerStatistics({
|
|
161
|
-
logMessage: `${this.log.getOptions().prefix} request statistics:`,
|
|
162
|
-
...statisticsOptions,
|
|
163
|
-
});
|
|
164
169
|
this.preventDirectStorageAccess = preventDirectStorageAccess;
|
|
165
170
|
}
|
|
166
171
|
async _init() {
|
|
@@ -238,7 +238,7 @@ export declare class PlaywrightCrawler<ContextExtension = Dictionary<never>, Ext
|
|
|
238
238
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
239
239
|
keepAlive: import("ow").BooleanPredicate & import("ow").BasePredicate<boolean | undefined>;
|
|
240
240
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
241
|
-
|
|
241
|
+
statistics: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
|
|
242
242
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
243
243
|
id: import("ow").StringPredicate & import("ow").BasePredicate<string | undefined>;
|
|
244
244
|
};
|
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.103",
|
|
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.0.0"
|
|
@@ -49,13 +49,13 @@
|
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@apify/datastructures": "^2.0.3",
|
|
51
51
|
"@apify/timeout": "^0.4.4",
|
|
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/types": "4.0.0-beta.
|
|
58
|
-
"@crawlee/utils": "4.0.0-beta.
|
|
52
|
+
"@crawlee/basic": "4.0.0-beta.103",
|
|
53
|
+
"@crawlee/browser": "4.0.0-beta.103",
|
|
54
|
+
"@crawlee/browser-pool": "4.0.0-beta.103",
|
|
55
|
+
"@crawlee/cheerio": "4.0.0-beta.103",
|
|
56
|
+
"@crawlee/core": "4.0.0-beta.103",
|
|
57
|
+
"@crawlee/types": "4.0.0-beta.103",
|
|
58
|
+
"@crawlee/utils": "4.0.0-beta.103",
|
|
59
59
|
"cheerio": "^1.0.0",
|
|
60
60
|
"idcac-playwright": "^0.1.3",
|
|
61
61
|
"jquery": "^3.7.1",
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
},
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "fe5d0ae11067683e27a2d17b4edd226ccf112cf5"
|
|
89
89
|
}
|