Skip to content

Instantly share code, notes, and snippets.

@n9ti
Created August 31, 2014 18:31
Show Gist options
  • Save n9ti/af59bed4b41f06b18833 to your computer and use it in GitHub Desktop.
Save n9ti/af59bed4b41f06b18833 to your computer and use it in GitHub Desktop.
Cheerio Example
var request = require('request');
var cheerio = require('cheerio');
request.get(
'http://en.wikipedia.org/wiki/Stack_(abstract_data_type)',
function (error, response, body) {
if (!error && response.statusCode == 200) {
extractData(body);
}
}
);
function extractData(body){
$ = cheerio.load(body);
var h1 = $('h1.firstHeading');
console.log(h1.text());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment