utils.puppeteer.blockRequests - how to enable with PuppeteerCrawler?

If I’m creating a crawler using new Apify.PuppeteerCrawler({…}), how do i set it to use utils.puppeteer.blockRequests?

(calling await Apify.utils.puppeteer.blockRequests(page) on top of handlePageFunction doesn’t work, presumably as goto is already called in that case.)

You need to override the default gotoFunction with a custom one using options.gotoFunction.

Such as:

const crawler = new Apify.PuppeteerCrawler({
    gotoFunction: async ({ request, page }) => {
        await Apify.utils.puppeteer.blockRequests(page);
        return page.goto(request.url, { timeout: 60000 });
    },
    // ...
})