@crawlee/playwright 4.0.0-beta.184 → 4.0.0-beta.185
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.
|
@@ -185,12 +185,8 @@ export class AdaptivePlaywrightCrawler extends BasicCrawler {
|
|
|
185
185
|
});
|
|
186
186
|
this.#staticCrawler = staticCrawler;
|
|
187
187
|
this.#browserCrawler = browserCrawler;
|
|
188
|
-
this.#staticContextPipeline = staticCrawler.contextPipeline.compose(
|
|
189
|
-
|
|
190
|
-
});
|
|
191
|
-
this.#browserContextPipeline = browserCrawler.contextPipeline.compose({
|
|
192
|
-
action: this.adaptPlaywrightContext.bind(this),
|
|
193
|
-
});
|
|
188
|
+
this.#staticContextPipeline = staticCrawler.contextPipeline.compose(this.adaptCheerioContext.bind(this));
|
|
189
|
+
this.#browserContextPipeline = browserCrawler.contextPipeline.compose(this.adaptPlaywrightContext.bind(this));
|
|
194
190
|
}
|
|
195
191
|
async init() {
|
|
196
192
|
// A crawler can be run again after a teardown.
|
|
@@ -202,34 +198,32 @@ export class AdaptivePlaywrightCrawler extends BasicCrawler {
|
|
|
202
198
|
}
|
|
203
199
|
buildContextPipeline() {
|
|
204
200
|
const errorMessage = (prop) => `The \`${prop}\` property is not available on the outer context pipeline of AdaptivePlaywrightCrawler - it is provided by the inner (static/browser) pipelines`;
|
|
205
|
-
return super.buildContextPipeline().compose({
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
}),
|
|
232
|
-
});
|
|
201
|
+
return super.buildContextPipeline().compose(async ({ request }) => ({
|
|
202
|
+
get request() {
|
|
203
|
+
return request;
|
|
204
|
+
},
|
|
205
|
+
get response() {
|
|
206
|
+
throw new Error(errorMessage('response'));
|
|
207
|
+
},
|
|
208
|
+
get page() {
|
|
209
|
+
throw new Error(errorMessage('page'));
|
|
210
|
+
},
|
|
211
|
+
get querySelector() {
|
|
212
|
+
throw new Error(errorMessage('querySelector'));
|
|
213
|
+
},
|
|
214
|
+
get querySelectorAll() {
|
|
215
|
+
throw new Error(errorMessage('querySelectorAll'));
|
|
216
|
+
},
|
|
217
|
+
get waitForSelector() {
|
|
218
|
+
throw new Error(errorMessage('waitForSelector'));
|
|
219
|
+
},
|
|
220
|
+
get parseWithCheerio() {
|
|
221
|
+
throw new Error(errorMessage('parseWithCheerio'));
|
|
222
|
+
},
|
|
223
|
+
get enqueueLinks() {
|
|
224
|
+
throw new Error(errorMessage('enqueueLinks'));
|
|
225
|
+
},
|
|
226
|
+
}));
|
|
233
227
|
}
|
|
234
228
|
async adaptCheerioContext(cheerioContext) {
|
|
235
229
|
return {
|
|
@@ -306,12 +300,16 @@ export class AdaptivePlaywrightCrawler extends BasicCrawler {
|
|
|
306
300
|
Object.defineProperty(subCrawlerContext, key, { ...descriptor, configurable: false });
|
|
307
301
|
}
|
|
308
302
|
try {
|
|
303
|
+
// Any failure - middleware or handler - ends up in the `ok: false` branch below.
|
|
304
|
+
const rethrow = (error) => {
|
|
305
|
+
throw error;
|
|
306
|
+
};
|
|
309
307
|
const callAdaptiveRequestHandler = async () => {
|
|
310
308
|
if (renderingType === 'static') {
|
|
311
|
-
await this.#staticContextPipeline.call(subCrawlerContext, this.requestHandler.bind(this));
|
|
309
|
+
await this.#staticContextPipeline.call(subCrawlerContext, this.requestHandler.bind(this), rethrow);
|
|
312
310
|
}
|
|
313
311
|
else if (renderingType === 'clientOnly') {
|
|
314
|
-
await this.#browserContextPipeline.call(subCrawlerContext, this.requestHandler.bind(this));
|
|
312
|
+
await this.#browserContextPipeline.call(subCrawlerContext, this.requestHandler.bind(this), rethrow);
|
|
315
313
|
}
|
|
316
314
|
};
|
|
317
315
|
// this crawler overrides `runRequestHandler` and times each rendering-type run itself, so it has
|
|
@@ -107,7 +107,7 @@ export class PlaywrightCrawler extends BrowserCrawler {
|
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
109
|
buildContextPipeline() {
|
|
110
|
-
return super.buildContextPipeline().compose(
|
|
110
|
+
return super.buildContextPipeline().compose(this.enhanceContext.bind(this));
|
|
111
111
|
}
|
|
112
112
|
async navigationHandler(crawlingContext, gotoOptions) {
|
|
113
113
|
return gotoExtended(crawlingContext.page, crawlingContext.request, gotoOptions);
|
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.185",
|
|
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": "^3.0.1",
|
|
51
51
|
"@apify/timeout": "^1.0.1",
|
|
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.185",
|
|
53
|
+
"@crawlee/browser": "4.0.0-beta.185",
|
|
54
|
+
"@crawlee/browser-pool": "4.0.0-beta.185",
|
|
55
|
+
"@crawlee/cheerio": "4.0.0-beta.185",
|
|
56
|
+
"@crawlee/core": "4.0.0-beta.185",
|
|
57
|
+
"@crawlee/types": "4.0.0-beta.185",
|
|
58
|
+
"@crawlee/utils": "4.0.0-beta.185",
|
|
59
59
|
"cheerio": "^1.0.0",
|
|
60
60
|
"jquery": "^3.7.1",
|
|
61
61
|
"ml-logistic-regression": "^2.0.0",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "642c670956a5a60384d5ed5e67ee809927cc419b"
|
|
84
84
|
}
|