Puppeteer Cluster-如何获取错误代码?

时间:2019-12-28 21:54:23

标签: node.js puppeteer puppeteer-cluster

有没有一种方法可以只接收错误代码,而无需说明?例如,仅获取ERR_NAME_NOT_RESOLVED而不是net::ERR_NAME_NOT_RESOLVED at https://domain.invalid/

Js:

const { Cluster } = require('puppeteer-cluster');

(async () => {
    // Create a cluster with 2 workers
    const cluster = await Cluster.launch({
        concurrency: Cluster.CONCURRENCY_CONTEXT,
        maxConcurrency: 2,
    });

    cluster.on('taskerror', (err, data) => {
        console.log(err.message);
    });


    await cluster.task(async ({ page, data: url }) => {
        await page.goto(url, { waitUntil: 'domcontentloaded' });
    });

    cluster.queue('https://domain.invalid/'); 

    await cluster.idle();
    await cluster.close();
})();

0 个答案:

没有答案