Created
May 19, 2018 19:48
-
-
Save OliPassey/d4b95a226fe10193f2e679a7a2668a00 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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