Last active
July 27, 2018 21:09
-
-
Save tomer-yoskovich/9eef60f7eb9e164362080c5c8c04a816 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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