Skip to content

Instantly share code, notes, and snippets.

@OliPassey
Created May 19, 2018 19:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OliPassey/d4b95a226fe10193f2e679a7a2668a00 to your computer and use it in GitHub Desktop.
Save OliPassey/d4b95a226fe10193f2e679a7a2668a00 to your computer and use it in GitHub Desktop.
var CronJob = require('cron').CronJob;
var job = new CronJob({
cronTime: '00 */5 * * * *',
onTick: function() {
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setViewport({width: 1920, height: 1080});
await page.goto('YOUR-URL-HERE', {waitUntil: 'networkidle0', timeout: 10000});
await page.screenshot({path: 'c:/folder/file.png'});
await page.goto('YOUR-URL-HERE', {waitUntil: 'networkidle0', timeout: 60000});
await page.screenshot({path: 'c:/folder/file.png',
clip: {
x: 275,
y: 92,
width: 1370,
height: 750
}});
await page.goto('YOUR-URL-HERE', {waitUntil: 'networkidle0', timeout: 60000});
await page.screenshot({path: 'c:/folder/file.png',
clip: {
x: 275,
y: 92,
width: 1370,
height: 750
}});
await page.goto('YOUR-URL-HERE', {waitUntil: 'networkidle0', timeout: 60000});
await page.screenshot({path: 'c:/folder/file.png',
clip: {
x: 275,
y: 92,
width: 1370,
height: 750
}});
await browser.close();
})();
},
start: false,
timeZone: 'Europe/London'
});
job.start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment