1.1.12 • Published 11 years ago

docparse-scraper-check-node v1.1.12

Weekly downloads
5
License
-
Repository
github
Last release
11 years ago

Docparse Scraper Check

Allow node based scrapers to query the docparse api and see if they should download a bill or not

Installation

npm install docparse-scraper-check

Usage

Call the module with your bill number, supplier code, and config object to check if a bill should get downloaded or not

var path = require('path')
var check = require('docparse-scraper-check');
var inspect = require('eyespect').inspector();
// get a config object
var configFilePath = path.join(__dirname, 'testConfig.json');
var config = require('docparse-config')(configFilePath);

var checkData = {
  supplierCode: 'HES',
  billNumber: 'H1268729'
}
check(checkData, function(err, reply) {
  if (err) {
    inspect(err, 'error checking to see if we should download a bill
  }
  inspect(reply, 'check reply');
}

You can also pass in an array with the key billNumbers. If your billNumber appears in this array, the system can avoid a remote api call and return results quicker

The reply in the check callback will be the json data parsed from the docparse api server check request. It should look like as follows:

New Bills

var reply = {
  download: true,
  message: 'Bill not yet download. Perform download now.',
  success: true
}

Existing Bills

var reply = {
  download: false,
  message: 'Bill already download. Do not download.',
  success: true
}