page.on('request', req => {
try {
const whitelist = ['document', 'script', 'xhr', 'fetch'];
requestUrl = req.url();
if (!whitelist.includes(req.resourceType())) {
return req.abort();
}
req.continue();
} catch(err) {
console.log(err);
}
});
await page.goto(url , {waitUntil: 'networkidle0'});
我使用puppeteer来过滤不必要的资源,例如CSS或媒体。但是我的服务器仍然可以收到CSS请求。为什么?