docparse-scraper-check-node

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

npm install docparse-scraper-check-node
40 downloads in the last month

Docparse Scraper Check Node

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

Installation

npm install docparse-scraper-check-node

Usage

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

var check = require('docparse-scraper-check-node');
// get an api object containing login credentials to the docparse server
var checkData = {
  supplierCode: 'HES',
  billNumber: 'H1268729',
  db: db // a cradle db connection
}
check(checkData, function(err, reply) {
  if (err) {
    console.dir(err)
    return
  }
  console.dir(reply)
}

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
}

Local Cache

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

var billNumbers =
var checkData = {
  supplierCode: 'HES',
  billNumber: 'bar',
  billNumbers: ['foo', 'bar'],
  db: db
}
check(checkData, function(err, reply) {
  if (err) {
    console.dir(err)
  }
  console.dir(reply)
}
npm loves you