可能循环个 10 次会遇到一两次,内存也够用 catch TargetCloseError: Protocol error (Emulation.setTouchEmulationEnabled): Session closed. Most likely the page has been closed.
for (let index = i; index < urls.length; ) {
let item = urls[index];
const page = await browser.newPage();
page.setDefaultTimeout(0);
page.setDefaultNavigationTimeout(0);
await page.setViewport({ width: 1080, height: 1024 });
await page.goto(item, {
waitUntil: "domcontentloaded",
protocolTimeout: 600000,
});
console.log("goto");
xxxxx...
}
1
youngbin0514 15 天前
你这个每次都新建一个页面吧,用完得 close 吧
|
2
tomiaa OP @youngbin0514 close 也是一样,也试了全局新建了一个 page 循环里面去 goto 跳转页面还是会报错
|