Answer the question
In order to leave comments, you need to log in
How to take screenshots of multiple sites with puppeteer?
Good afternoon, there is a puppeteer function to take a screenshot of a web page.
const puppeteer = require('puppeteer');
const siteURL = 'http://example.com'
async function getPic() {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setViewport({width: 1600, height: 1200});
await page.goto(siteURL,{ waitUntil: 'networkidle2' });
await page.screenshot({path: '__PNG.png', fullPage: true});
await browser.close();
}
Answer the question
In order to leave comments, you need to log in
Somehow it's still possible.
$(window).on('scroll.toElement', function (e) {
var s_top = $("body").scrollTop();
var el = $("#popular").offset().top;
if(s_top > el){
console.log('123');
$(window).off('scroll.toElement');
}
});
const puppeteer = require('puppeteer');
const siteURLs = ['http://example0.com', 'http://example1.com', 'http://example2.com'];
function makeScreenshotFromSite(url, page) {
return page.setViewport({width: 1600, height: 1200})
.then(() => {
return page.goto(siteURL,{ waitUntil: 'networkidle2' });
})
.then(() => {
return page.screenshot({path: '__PNG.png', fullPage: true});
});
};
async function start(sites) {
const browser = await puppeteer.launch();
const page = await browser.newPage();
const someRes = await Promise.all(
sites.map(makeScreenshotFromSite)
);
await browser.close();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question