Puppeteer wait for all images to load then take screenshot

前端 未结 5 1128
抹茶落季
抹茶落季 2020-12-23 16:38

I am using Puppeteer to try to take a screenshot of a website after all images have loaded but can\'t get it to work.

Here is the code I\'ve got so far, I am using h

5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-23 17:09

    There is a built-in option for that:

    await page.goto('https://www.digg.com/', {"waitUntil" : "networkidle0"});
    

    networkidle0 - consider navigation to be finished when there are no more than 0 network connections for at least 500 ms

    networkidle2 - consider navigation to be finished when there are no more than 2 network connections for at least 500 ms.

    P.S. Of course it won't work if you're working with endless-scrolling-single-page-applications like Twitter.

提交回复
热议问题