docparse-scraper-nst
Version:
Node Zombie based scraper to scrape bills from the NStar (supplier code "NST)" website
23 lines (22 loc) • 875 B
JavaScript
var atLoginPage = require('./atLoginPage');
var inspect = require('eyespect').inspector();
var logout = require('./logout');
module.exports = function(data,cb) {
inspect('going to login page');
data.bro.visit('http://nstar.com/business', function (err, bro, status) {
bro.wait(function(err) {
var html = data.bro.evaluate('document.documentElement.outerHTML');
var atPage = atLoginPage(data);
if (atPage) { return cb(); }
// if we are already logged in we will land at the account homepage. In this
// case we want to log out and start fresh as we might be scraping for a
// different customer login
logout(data, function(err, reply) {
if (err) { return cb(err); }
atPage = atLoginPage(data.bro);
if (atPage) { return cb(); }
return cb('failed to get to login page');
})
});
});
}