where to hook 'Puppeteer request interceptor'
Hi
Where in crawlee is the best place to hook Puppeteer 'request interceptor'.
I mean mechanizm like here
// pure puppeteer code
const browser = await puppeteer.launch({ headless: true })
const page = await browser.newPage()
// here starts interceptor
await page.setRequestInterception(true);
page.on('request', (request) => {
if (['image', 'stylesheet'].indexOf(request.resourceType()) !== -1) {
request.abort();
} else {
request.continue();
}
});
Thank you!6 Replies
vicious-gold•3y ago
Hey there - it's normally in
preNavigationHooks
as you want to start intercepting before the navigation starts. If you have something specific - e.g. press a button and intercept a request - you could do it wherever (even in requestHandler
) before pressing the buttonsensitive-blueOP•3y ago
Thank you again, it works ;]
@Deleted User just advanced to level 1! Thanks for your contributions! 🎉
old-apricot•3y ago
hi, this is not working for playwright context
wise-white•3y ago
It should work for Playwright too.
Can you share some code snippet with your implementation of request interception ?
fascinating-indigo•3y ago
@Bilal Ghouri Playwright uses https://playwright.dev/docs/api/class-page#page-route
Page | Playwright
* extends: [EventEmitter]