puppeteer 确定页面跳转完成

2 min read
  • load - 页面的load事件触发时
  • domcontentloaded - 页面的DOMContentLoaded事件触发时
  • networkidle0 - 不再有网络连接时触发(至少500毫秒后)
  • networkidle2 - 只有2个网络连接时触发(至少500毫秒后)
const page = await browser.newPage()
await page.goto(url, {
    waitUntil: 'networkidle0'
})