1const puppeteer = require('puppeteer');
2
3(async () => {
4 const browser = await puppeteer.launch();
5 const page = await browser.newPage();
6 await page.goto('https://news.ycombinator.com', {waitUntil: 'networkidle2'});
7 await page.pdf({path: 'hn.pdf', format: 'A4'});
8
9 await browser.close();
10})();
1const puppeteer = require('puppeteer');
2
3(async () => {
4 const browser = await puppeteer.launch();
5 const page = await browser.newPage();
6 await page.goto('https://example.com');
7 await page.screenshot({path: 'example.png'});
8
9 await browser.close();
10})();