0.2.2 • Published 8 years ago

grabby v0.2.2

Weekly downloads
25
License
MIT
Repository
github
Last release
8 years ago

Grabby

NPM Build Status

Features

  • request compatibility
  • promise interface
  • encoding detection(utf8, win1251)
  • compressing detection(gzip, deflate)
  • debug support

Install

npm install grabby --save

Nice and fancy

var grabby = require('grabby');

// same as original node request
var request = {url: 'http://yandex.ru'};

// returns Promise
grabby.requestHtml(request).then(function (html) {
    // for example parse http with cheerio
    var $ = cheerio.load(html);
});

Advanced usage

var grabby = require('grabby');

// set fail reason and grabby will continue to try
// useful if you meet nginx with request per minute limit
grabby.requestHtml({
    url: '',
    attempt: {
        reason: [409], // status code
        reason: function (error, response) { // or your own reason
            /* check response */
        },
        delay: 100, // constant in ms
        delay: function (n) { // or even your custom value
            return 100 * n;
        },
        limit: 10 // reject promise after 10 tries
    }
});

Debug support

Debug mode is provided through the use of the debug module. To enable:

DEBUG=grabby node your_program.js

or even in your script

// set debug environment
process.env['debug'] = 'grabby';

Read the debug module documentation for more details.

Tests

npm test
0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

9 years ago

0.1.9

9 years ago

0.1.8

10 years ago

0.1.7

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.3

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago