const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setViewport({ width: 640, height: 480, deviceScaleFactor: 1 });
let shotNum = 0
let interval = setInterval(/*async*/() => {
/*await*/ page.screenshot({ path: `example.png${shotNum++}` })
}, 500);
page.goto('https://example.com', {
//https://pptr.dev/#?product=Puppeteer&version=v5.0.0&show=api-pagewaitfornavigationoptions
waitUntil: "domcontentloaded" //"networkidle2" //"networkidle0" //"load"
}).then(async () => {
clearInterval(interval)
await browser.close();
})
})();