cheerful

2.2.1 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i cheerful

Weekly Downloads

1

Version

2.2.1

License

MIT

Last publish

Collaborators