Skip to content

Instantly share code, notes, and snippets.

@DanNi0130
Last active July 19, 2018 02:14
Show Gist options
  • Save DanNi0130/c608772ae888521b527d91bae7f0b418 to your computer and use it in GitHub Desktop.
Save DanNi0130/c608772ae888521b527d91bae7f0b418 to your computer and use it in GitHub Desktop.
const puppeteer = require('puppeteer');
const $ = require('cheerio');
const url = 'https://www.reddit.com';
puppeteer
.launch()
.then(function(browser) {
return browser.newPage();
})
.then(function(page) {
return page.goto(url).then(function() {
return page.content();
});
})
.then(function(html) {
$('h2', html).each(function() {
console.log($(this).text());
});
})
.catch(function(err) {
//handle error
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment