cheerful
v2.2.1
Published
the composition of cheerio and hyperquestionable
Downloads
3
Readme
cheerful
the composition of Cheerio and hyperquestionable
Installation
$ npm install cheerful
API
var request$ = require('cheerful')
request$(url, function cb(err, $))
request url using hyperquestionable, run it through cheerio and hand it back to you. The HTTP status code is added to the Cheerio object and to Cheerio errors as statusCode.
Example:
var request$ = require('cheerful')
request$('http://google.com', findDoodle)
function findDoodle(err, $) {
var headers = (err || $).headers
if (headers && headers.location)
return request$(headers.location, findDoodle)
if (err) return console.error('error', err)
var div = $('center div[title="Google"]')
var img = 'http://google.com'+ div.attr('style').match(/url\((\S+)\)/)[1]
console.log('today\'s Google Doodle:', img)
}
License
MIT