Skip to content

Instantly share code, notes, and snippets.

@senthilmpro
Last active May 3, 2018 17:12
Show Gist options
  • Save senthilmpro/99b057e42801bc97badad2ca49f557fe to your computer and use it in GitHub Desktop.
Save senthilmpro/99b057e42801bc97badad2ca49f557fe to your computer and use it in GitHub Desktop.
Block images from loading - Google Puppeteer
'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