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
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 button
sensitive-blue
sensitive-blueOP•3y ago
Thank you again, it works ;]
MEE6
MEE6•3y ago
@Deleted User just advanced to level 1! Thanks for your contributions! 🎉
old-apricot
old-apricot•3y ago
hi, this is not working for playwright context
wise-white
wise-white•3y ago
It should work for Playwright too. Can you share some code snippet with your implementation of request interception ?
fascinating-indigo
fascinating-indigo•3y ago
Page | Playwright
* extends: [EventEmitter]

Did you find this page helpful?