Created
September 15, 2017 14:09
-
-
Save aanton/b4c9cedc0dd2437703d86507c69cdffe to your computer and use it in GitHub Desktop.
Puppeteer screenshot demo
This file contains hidden or 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
'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(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment