page.setRequestInterception(true)
How to I can use page.setRequestInterception(true) in PuppeteerCrawler (not use raw Puppeteer)
9 Replies
@songoku just advanced to level 2! Thanks for your contributions! 🎉
ratty-blush•3y ago
preNavigationHooks
is the right place for it:
https://crawlee.dev/api/puppeteer-crawler/interface/PuppeteerCrawlerOptions#preNavigationHooks
Example:
stormy-goldOP•3y ago
thank you
quickest-silver•3y ago
you enabling http requests tracking, after that you need to
page.on('request')
(or response) if you not adding your own logic to process responses or requests then it makes no sense to enable interception, right? 😉stormy-goldOP•3y ago
I want to obtain respone ajax from request main URL
conscious-sapphire•3y ago
@songoku the Ajax request is made on the page?
stormy-goldOP•3y ago
yes
conscious-sapphire•3y ago
Within your
preNavigationHooks
, you can add a function that looks like this. It will listen for responses:
optimistic-gold•3y ago
Yes, you don't need request interception at all. You only care about responses. You can also scrape the ajax directly as explained here https://developers.apify.com/academy/api-scraping
Apify
API scraping · Apify Developers
Learn all about how the professionals scrape various types of APIs with various configurations, parameters, and requirements.