@crawlee/playwright 3.17.1-beta.0 → 3.17.1-beta.10
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.
|
@@ -132,7 +132,7 @@ async function clickElementsAndInterceptNavigationRequests(options) {
|
|
|
132
132
|
await restoreHistoryNavigationAndSaveCapturedUrls(page, uniqueRequests);
|
|
133
133
|
// browser.off(BrowserEmittedEvents.TargetCreated, onTargetCreated);
|
|
134
134
|
page.off('framenavigated', onFrameNavigated);
|
|
135
|
-
await context.unroute('
|
|
135
|
+
await context.unroute('**', onInterceptedRequest);
|
|
136
136
|
const serializedRequests = Array.from(uniqueRequests);
|
|
137
137
|
return serializedRequests.map((r) => JSON.parse(r));
|
|
138
138
|
}
|
|
@@ -176,7 +176,16 @@ function createTargetCreatedHandler(requests) {
|
|
|
176
176
|
* @ignore
|
|
177
177
|
*/
|
|
178
178
|
function isTopFrameNavigationRequest(page, req) {
|
|
179
|
-
|
|
179
|
+
try {
|
|
180
|
+
return req.isNavigationRequest() && req.frame() === page.mainFrame();
|
|
181
|
+
}
|
|
182
|
+
catch {
|
|
183
|
+
// `req.frame()` throws when the owning frame is unavailable - e.g. the request was
|
|
184
|
+
// issued by a service worker, or before/after its frame existed (see #3216). Such a
|
|
185
|
+
// request is not a top-frame navigation, so swallow the throw and let it pass through
|
|
186
|
+
// instead of crashing the route handler (which would leave the route unhandled).
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
180
189
|
}
|
|
181
190
|
/**
|
|
182
191
|
* @ignore
|
|
@@ -511,7 +511,9 @@ async function handleCloudflareChallenge(page, url, session, options = {}) {
|
|
|
511
511
|
});
|
|
512
512
|
options.isChallengeCallback ?? (options.isChallengeCallback = async () => {
|
|
513
513
|
return await page.evaluate(async () => {
|
|
514
|
-
|
|
514
|
+
// Cloudflare nests the ray ID under varying wrapper elements, so we match by descendants
|
|
515
|
+
// instead of a direct-child chain (e.g. a `.footer-wrapper` was inserted in between).
|
|
516
|
+
return !!document.querySelector('.footer .footer-inner .diagnostic-wrapper .ray-id');
|
|
515
517
|
});
|
|
516
518
|
});
|
|
517
519
|
const retryBlocked = async () => {
|
|
@@ -532,7 +534,10 @@ async function handleCloudflareChallenge(page, url, session, options = {}) {
|
|
|
532
534
|
log[logLevel](`Detected Cloudflare challenge at ${url}, trying to solve it. This can take up to ${10 + (options.sleepSecs ?? 10)} seconds.`);
|
|
533
535
|
const bb = await page
|
|
534
536
|
.evaluate(() => {
|
|
535
|
-
|
|
537
|
+
// Prefer the actual challenge widget (the box holding the Turnstile checkbox input);
|
|
538
|
+
// fall back to the first content div for older challenge layouts.
|
|
539
|
+
const div = document.querySelector('.main-content div:has(input[id^="cf-chl-widget-"])') ??
|
|
540
|
+
document.querySelector('.main-content div');
|
|
536
541
|
return div?.getBoundingClientRect();
|
|
537
542
|
})
|
|
538
543
|
.catch(() => undefined);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crawlee/playwright",
|
|
3
|
-
"version": "3.17.1-beta.
|
|
3
|
+
"version": "3.17.1-beta.10",
|
|
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"
|
|
@@ -56,11 +56,11 @@
|
|
|
56
56
|
"@apify/datastructures": "^2.0.0",
|
|
57
57
|
"@apify/log": "^2.4.0",
|
|
58
58
|
"@apify/timeout": "^0.3.1",
|
|
59
|
-
"@crawlee/browser": "3.17.1-beta.
|
|
60
|
-
"@crawlee/browser-pool": "3.17.1-beta.
|
|
61
|
-
"@crawlee/core": "3.17.1-beta.
|
|
62
|
-
"@crawlee/types": "3.17.1-beta.
|
|
63
|
-
"@crawlee/utils": "3.17.1-beta.
|
|
59
|
+
"@crawlee/browser": "3.17.1-beta.10",
|
|
60
|
+
"@crawlee/browser-pool": "3.17.1-beta.10",
|
|
61
|
+
"@crawlee/core": "3.17.1-beta.10",
|
|
62
|
+
"@crawlee/types": "3.17.1-beta.10",
|
|
63
|
+
"@crawlee/utils": "3.17.1-beta.10",
|
|
64
64
|
"cheerio": "1.0.0-rc.12",
|
|
65
65
|
"jquery": "^3.6.0",
|
|
66
66
|
"lodash.isequal": "^4.5.0",
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
},
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "2c63bfc2cf7471408ea7e1c0aee385adc2e78971"
|
|
93
93
|
}
|