Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // install:
- // npm i puppeteer
- // run (assuming this script is save as BrowserScreen.js):
- // node BrowserScreen.js
- // the script is saving a screenshot of the website every second to fresh-screenshot.png
- const puppeteer = require('puppeteer');
- (async () => {
- takeScreenshot = async function () {
- await page.screenshot({ path: "fresh-screenshot.png" , omitBackground: true}); // use your own file name
- console.log("Screenshot image is now fresh");
- setTimeout(takeScreenshot, 1000);
- }
- const browser = await puppeteer.launch();
- const page = await browser.newPage();
- await page.goto('https://www.unixtimestamp.com/'); // use your own URL
- // // use this if your web page doesn't have transparent background by CSS:
- // await page.evaluate(() => document.body.style.background = 'transparent');
- takeScreenshot();
- // await browser.close(); // this should be called once the script is finished
- }) ();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement