Skip to content

Instantly share code, notes, and snippets.

@tomer-yoskovich
Last active July 27, 2018 21:09
Show Gist options
  • Save tomer-yoskovich/9eef60f7eb9e164362080c5c8c04a816 to your computer and use it in GitHub Desktop.
Save tomer-yoskovich/9eef60f7eb9e164362080c5c8c04a816 to your computer and use it in GitHub Desktop.
const puppeteer = require('puppeteer');
// IIFE async pattern (more below)
(async () => {
// opens the chromium browser
const browser = await puppeteer.launch({
headless: false, // when debugging we prefer seeing the browser in action
slowMo: 250 // slow down puppeteer actions so we can see what's going on (in ms)
});
// create a new tab, which is represented by a 'page' object
const page = await browser.newPage();
// ask that tab to navigate to a specific URL
await page.goto('https://example.com');
// take a screenshot of that page and save it as 'example.png' in current directory
await page.screenshot({path: 'example.png'});
// close browser and all of its open tabs
await browser.close();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment