📜  puppeteer 在第二页后打印页码 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:10.246000             🧑  作者: Mango

代码示例1
if (!this.browser) {
    this.browser = await puppeteer.launch(this.OPT)
    const pages: puppeteer.Page[] = await this.browser.pages()

    // close chromium by catching 'targetdestryed'
    this.browser.on('targetdestroyed', async () => {
      if (this.browser) {
        const pages: puppeteer.Page[] = await this.browser.pages()
        if (pages.length === 0) {
          process.exit(0)
        }
      }
    })
  }