Skip to content

Instantly share code, notes, and snippets.

@5shekel
Created November 27, 2018 22:09
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 5shekel/847c3040ffd37328367bf3df206058f1 to your computer and use it in GitHub Desktop.
Save 5shekel/847c3040ffd37328367bf3df206058f1 to your computer and use it in GitHub Desktop.
//grab a screenshot using chromedriver headless
//grab a screenshot using chromedriver headless
//see install of pupetter on
//https://pptr.dev/
const puppeteer = require('puppeteer');
// print process.argv
console.log(process.argv.length);
if (process.argv.length <= 2) {
console.log("Usage: " + __filename + " URL and IMAGE.jpg");
process.exit(-1);
}
process.argv.forEach(function (val, index, array) {
console.log(index + ': ' + val);
});
(async () => {
//follow the readme and enable sandbox on your kernel
const browser = await puppeteer.launch();
//also possible to run without sandbox, like this
/// ...pupeteer.launch({args: ['--no-sandbox','--disable-setuid-sandbox']});
const page = await browser.newPage();
await page.goto(process.argv[2]);
await page.screenshot({path: process.argv[3]});
await browser.close();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment