Skip to content

Instantly share code, notes, and snippets.

@akagisho
Created June 3, 2018 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akagisho/d6ab6ec8253c7a152507e8cbce10c99e to your computer and use it in GitHub Desktop.
Save akagisho/d6ab6ec8253c7a152507e8cbce10c99e to your computer and use it in GitHub Desktop.
const viewportWidth = 1200;
const viewportHeight = 900;
const argv = process.argv;
var path = require('path');
const puppeteer = require('puppeteer');
if (argv.length < 3) {
console.error('Usage: node ' + path.basename(argv[1]) + ' <path> <url>');
process.exit(1);
}
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
page.setViewport({width: viewportWidth, height: viewportHeight});
await page.goto(argv[3]);
page.evaluate(_ => {
window.scrollBy(0, window.innerHeight);
});
await page.screenshot({
path: argv[2],
fullPage: true
});
await browser.close();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment