Created
February 21, 2019 08:48
-
-
Save gippy/df298d2142918ef3f4732ac5a97b6b82 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
const Apify = require('apify'); | |
const { PuppeteerCrawler } = Apify; | |
const saveScreen = async (page, key = 'debug-screen') => { | |
const screenshotBuffer = await page.screenshot({ fullPage: true }); | |
await Apify.setValue(key, screenshotBuffer, { contentType: 'image/png' }); | |
}; | |
Apify.main(async () => { | |
// Get input of your actor | |
const input = await Apify.getValue('INPUT'); | |
const requestQueue = await Apify.openRequestQueue(); | |
await requestQueue.addRequest({ url: 'https://smash.gg/' }); | |
const cookies = [ | |
{ name: 'gg-client-cookie', domain: 'smash.gg', value: '<FILL HERE>' }, | |
{ name: 'gg-client-session', domain: 'smash.gg', value: '<FILL HERE>' }, | |
{ name: 'gg-drawerCollapsed', domain: 'smash.gg', value: '<FILL HERE>' }, | |
{ name: 'gg_notif', domain: 'smash.gg', value: '<FILL HERE>' }, | |
{ name: 'gg_session', domain: 'smash.gg', value: '<FILL HERE>' }, | |
]; | |
const crawler = new PuppeteerCrawler({ | |
requestQueue, | |
gotoFunction: async ({ page, request }) => { | |
await page.setCookie(...cookies); | |
return page.goto(request.url, { waitUntil: 'networkidle2' }); | |
}, | |
handlePageFunction: async ({ page }) => { | |
await saveScreen(page); | |
}, | |
}); | |
await crawler.run(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment