flat-fuchsia
flat-fuchsia•3y ago

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
national-gold
national-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
flat-fuchsia
flat-fuchsiaOP•3y ago
Thank you again, it works ;]
MEE6
MEE6•3y ago
@Deleted User just advanced to level 1! Thanks for your contributions! 🎉
generous-apricot
generous-apricot•3y ago
hi, this is not working for playwright context
Oleg V.
Oleg V.•3y ago
It should work for Playwright too. Can you share some code snippet with your implementation of request interception ?
Lukas Krivka
Lukas Krivka•3y ago
Page | Playwright
* extends: [EventEmitter]

Did you find this page helpful?