Advertisement
metalx1000

Puppeteer page screenshot

Jan 13th, 2024 (edited)
504
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. mkdir screenshot
  2. cd screenshot
  3. npm i puppeteer --save
  4.  
  5. ######SCRIPT######
  6. const puppeteer = require('puppeteer');
  7. const url = process.argv[2];
  8. if (!url) {
  9. throw "Please provide URL as a first argument";
  10. }
  11. async function run () {
  12. const browser = await puppeteer.launch({headless: 'new'});
  13. const page = await browser.newPage();
  14. await page.goto(url);
  15. await page.screenshot({path: 'screenshot.png'});
  16. browser.close();
  17. }
  18. run();
  19.  
  20. ########RUN#########
  21. node screenshot.js "https://filmsbykris.com"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement