Skip to content

Instantly share code, notes, and snippets.

@aanton
Created September 15, 2017 14:09
Show Gist options
  • Select an option

  • Save aanton/b4c9cedc0dd2437703d86507c69cdffe to your computer and use it in GitHub Desktop.

Select an option

Save aanton/b4c9cedc0dd2437703d86507c69cdffe to your computer and use it in GitHub Desktop.

Revisions

  1. aanton created this gist Sep 15, 2017.
    31 changes: 31 additions & 0 deletions puppeteer.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    'use strict';

    const puppeteer = require('puppeteer');

    (async() => {

    const browser = await puppeteer.launch({
    headless: true,
    ignoreHTTPSErrors: true,
    timeout: 1000
    });
    const page = await browser.newPage();

    await page.setRequestInterceptionEnabled(true);
    page.on('request', request => {
    if (request.resourceType === 'Script') {
    request.abort();
    } else {
    request.continue();
    }
    });

    await page.goto('http://listas.20minutos.es/');
    await page.screenshot({path: 'screenshot.png',
    clip: {x: 0, y:0, width: 1024, height: 800}
    });
    // await page.screenshot({path: 'screenshot-full.png', fullPage: true});

    browser.close();

    })();