Skip to content

Instantly share code, notes, and snippets.

@klogic
Created November 4, 2018 02:15
Show Gist options
  • Save klogic/aca628372aca38836428b607e92179c1 to your computer and use it in GitHub Desktop.
Save klogic/aca628372aca38836428b607e92179c1 to your computer and use it in GitHub Desktop.
const cron = require('node-cron');
cron.schedule('0 59 23 * * *', async function (){
let today = new Date();
let dd = today.getDate();
let mm = today.getMonth()+1;
let yyyy = today.getFullYear();
todaydate = `${dd}_${mm}_${yyyy}`;
filename = `geckoboard_${todaydate}.jpg`;
const browser = await puppeteer.launch({
executablePath: '/usr/bin/chromium-browser',
args: ['--no-sandbox', '--headless', '--disable-gpu']
}); //args for disable headless in linux
const page = await browser.newPage();
await page.setViewport({ width: 3840, height: 2400 , deviceScaleFactor: 3}); // get height resolution
await page.goto('https://www.geckoboard.com/learn/dashboard-examples/executive/ceo-dashboard-example');
await page.waitFor(15000);
await page.screenshot({path: filename});
console.log('screenshort has been take');
await browser.close();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment