osenvosem
01/04/2025, 11:01 AMHall
01/04/2025, 11:01 AM! Spooky
01/07/2025, 5:55 PMawait page.context().storageState({ path: authFilePath })
Look up storageState() on the playwright docsCrafty
01/20/2025, 2:21 PMOleg V.
01/20/2025, 4:21 PMCrafty
01/20/2025, 4:27 PMCrafty
01/20/2025, 4:28 PMCrafty
01/21/2025, 11:42 AMuseIncognitoPages
to true, you can modify the pageOptions to set your cookies and localStorage inside of a prePageCreateHook
typescript
const authStorage = await KeyValueStore.open('auth');
const crawler = new PlaywrightCrawler({
launchContext: {
launcher: chromium,
useIncognitoPages: true
},
requestHandler: router,
browserPoolOptions: {
prePageCreateHooks: [
async (pageId, browserController, pageOptions) => {
if (!pageOptions) { // pageOptions is only exposed in incognito
throw new Error("no page options")
}
pageOptions.storageState = await authStorage.getValue("state") ?? undefined
}
]
}
});
unfortunately this seems to add a fair chunk of overhead though.Crafty
01/21/2025, 12:11 PMjson
{"requestsFinished":37,"requestsFailed":0,"retryHistogram":[37],"requestAvgFailedDurationMillis":null,"requestAvgFinishedDurationMillis":3514,"requestsFinishedPerMinute":53,"requestsFailedPerMinute":0,"requestTotalDurationMillis":130001,"requestsTotal":37,"crawlerRuntimeMillis":42227}
without incognito (and the hook)
INFO PlaywrightCrawler: Final request statistics:
json
{"requestsFinished":37,"requestsFailed":0,"retryHistogram":[37],"requestAvgFailedDurationMillis":null,"requestAvgFinishedDurationMillis":2238,"requestsFinishedPerMinute":67,"requestsFailedPerMinute":0,"requestTotalDurationMillis":82813,"requestsTotal":37,"crawlerRuntimeMillis":32955}
ApifyBot
01/21/2025, 12:11 PMCrafty
01/21/2025, 3:04 PMexperimentalContainers
instead of useIncognitoPages
though it doesnt seem to work yetВан\
01/22/2025, 3:00 AM