0.2.10 • Published 9 years ago

minifridge v0.2.10

Weekly downloads
68
License
-
Repository
github
Last release
9 years ago

MiniFridge

Node module that combines the base http and https modules with cheerio for screen scraping.

Usage

1) Setup the module references in the files you want to use it in:

var miniFridge = require('minifridge');

2) Set the protocol to use:

miniFridge.setProtocol('http');

or

miniFridge.setProtocol('https');

3a) Build the options object. NOTE: the options object takes all the available parameters from the base http and https modules.

  var options = {
    host: 'www.test.com',
    port: 443,
    path: '/test/path',
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    rejectUnauthorized: true,
    followRedirects: true
  };

3b) Use the helper methods to construct the options object:

// build the request options.
var options = miniFridge.buildPostOptions('www.test.com',
                                        443,
                                        '/test/path',
                                        miniFridge.contentType.htmlForm,
                                        body,
                                        true);

// add a cookie to the options object.
miniFridge.addCookie(options, 'COOKIE_NAME', 'COOKIE_VALUE');

3) Execute a request:

miniFridge.request(options, body, function (error, data) {
    // handle error and data.
});

Note: The error object will be null unless an error was detected.
The data object is a cheerio object, so you can use the selector functions on it:

data.$('elementid');
0.2.10

9 years ago

0.2.9

9 years ago

0.2.8

9 years ago

0.2.7

9 years ago

0.2.6

9 years ago

0.2.5

9 years ago

0.2.4

9 years ago

0.2.3

9 years ago

0.2.2

9 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.5

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.0.1

10 years ago