有没有一种方法可以只接收错误代码,而无需说明?例如,仅获取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();
})();