puppeteer 禁用图片CSS字体加载

3 min read

puppeteer 禁用图片CSS加载

const puppeteer = require('puppeteer');
async function run() {
let browser = await puppeteer.launch({ headless: false });
let page = await browser.newPage();
await page.setViewport({ width: 1920, height: 1080 });
await page.setRequestInterception(true);
page.on('request', (req) => {
if(req.resourceType() == 'stylesheet' || req.resourceType() == 'font' || req.resourceType() == 'image'){
  req.abort();
  }
  else {
  	req.continue();
  	}
  });
await page.goto('https://www.ebay.com/');
}
run();