Skip to content

Instantly share code, notes, and snippets.

@gippy
Created February 21, 2019 08:48
Show Gist options
  • Save gippy/df298d2142918ef3f4732ac5a97b6b82 to your computer and use it in GitHub Desktop.
Save gippy/df298d2142918ef3f4732ac5a97b6b82 to your computer and use it in GitHub Desktop.
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