UNPKG

docparse-scraper-nst

Version:

Node Zombie based scraper to scrape bills from the NStar (supplier code "NST)" website

43 lines (41 loc) 1.08 kB
var async = require('async'); module.exports = function (data, callback) { var accountNumber = data.accountNumber; var logger = data.logger; var bills = data.bills; var output = {}; if (!bills) { bills = require('docparse-fetch-bills-node'); } var getBillDates = data.getBillDates; if (!getBillDates) { getBillDates = require('./getBillDates'); } async.series([ function (cb) { bills(data, function (err, billNumbers) { if (err) { return cb(err); } output.billNumbers = billNumbers; cb(); }); }, function (cb) { getBillDates(data, function (err, reply) { if (err) { logger.debug('error getting bill dates on account homepage', { type: 'scraper', supplierCode: 'NST', accountNumber: accountNumber, error: err }); return cb(err); } output.billDates = reply; cb(); }); } ], function (err, reply) { if (err) { return callback(err); } callback(null, output); }); };