Skip to content

Instantly share code, notes, and snippets.

Last active September 24, 2016 15:55
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
var cheerio = require('cheerio');
var request = require('request')
var prettyjson = require('prettyjson')
function gotHTML(err, resp, html) {
if (err) return console.error(err)
var parser = cheerio.load(html)
topic = {}
topic.title = parser('h2').text()
topic.story = parser('.display-post-story', '.main-post').text()
var options = {
url: '',
headers: {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36',
'accept': 'application/json',
'X-Requested-With': 'XMLHttpRequest'
request(options, function(err, resp, html) {
// console.log(prettyjson.render(resp.body))
// console.log(prettyjson.render(JSON.parse(resp.body).comments[0].emotion));
// console.log(prettyjson.render(JSON.parse(resp.body).comments[0].good_bad_vote));
req = request('', gotHTML)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment