请问 puppeteer 能不能 在 page goto 一个非标准 scheme 的 uri 时做 interception
代码如下,无法在page.on('request', xxx)
中监听到 request。 而是直接报错
const puppeteer = require('puppeteer-core');
const findChrome = require('./findChrome');
(async ()=>{
const { executablePath, type } = await findChrome({});
if (!executablePath) {
console.error('Could not find Chrome installation, please make sure Chrome browser is installed from https://www.google.com/chrome/.');
process.exit(0);
return;
}
const browser = await puppeteer.launch({
executablePath,
headless: false,
defaultViewport: null,
userDataDir: '.local-data',
});
let pages = await browser.pages();
let page = pages[0];
page.on('request', (request)=>{
console.log(request); // 👈 到达不了这里
request.continue();
});
page.on('requestfinished', (request)=>{
console.log(request);
})
await page.setRequestInterception(true);
try{
await page.goto('app://index.html');
}catch(err){
console.error(err);
}
})();
Error: net::ERR_ABORTED at app://index.html