How to ensure the quality of puppeteer batch screenshots

how to ensure the quality of puppeteer batch screenshots

outer for loop task list. Post the code inside

//  Chromium
      const browser = await puppeteer.launch({ ignoreHTTPSErrors: true, headless: true, args: ["--no-sandbox", "--disable-setuid-sandbox"] }).catch( err => {
        console.log("launch-err: " + err)
        reject("fail")
      })
      // 
      const page = await browser.newPage()
      // 
      await page.setViewport({ width: 1920, height: 1080 })

      // 
      console.log("website-> " + taskInfo[2])
      await page.goto(taskInfo[2], { waitUntil: ["domcontentloaded", "load","networkidle0"] }).catch(err => {
        console.log("goto-err-> " + err)
        reject("fail")
      })
      await page.waitFor(5000)

      try {
        // 
        await page.screenshot({ path: snapShotFolerPath + snapshotName, fullPage: true }).catch(err => {
          console.log("screenshot-err-> " + err)
          reject("fail")
        })
      } catch (e) {
        reject("fail")
        console.log("failed " + e)
      } 

the problem encountered now is that the screenshot can be successful, but it is found that some screenshots will encounter blank or 404. How can the bosses solve this problem


await page.waitFor(5000)

because you're just waiting for 5s , it doesn't necessarily have anything to do with the completion of the load. If the presence of an element means completion, you should use await page.waitForSelector , and if you have to wait for some front-end event or need a front-end script to determine completion, you can use await page.evaluate .

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1be5de4-13cf2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1be5de4-13cf2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?