Last active
July 19, 2018 02:14
-
-
Save DanNi0130/c608772ae888521b527d91bae7f0b418 to your computer and use it in GitHub Desktop.
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
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