Last active
May 3, 2018 17:12
-
-
Save senthilmpro/99b057e42801bc97badad2ca49f557fe to your computer and use it in GitHub Desktop.
Block images from loading - Google Puppeteer
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
'use strict'; | |
const puppeteer = require('puppeteer'); | |
(async() => { | |
const browser = await puppeteer.launch(); | |
const page = await browser.newPage(); | |
await page.setRequestInterception(true); | |
page.on('request', request => { | |
if (request.resourceType() === 'image') | |
request.abort(); | |
else | |
request.continue(); | |
}); | |
await page.goto('https://news.google.com/news/'); | |
await page.screenshot({path: 'news.png', fullPage: true}); | |
await browser.close(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment