Skip to content

Instantly share code, notes, and snippets.

@jbnicolai
Created February 10, 2014 20:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbnicolai/8923825 to your computer and use it in GitHub Desktop.
Save jbnicolai/8923825 to your computer and use it in GitHub Desktop.
CasperJS crawler and user info fetcher
var casper = require('casper').create({ verbose: true, logLevel: 'info' });
var credentials = JSON.parse(require('fs').read('./credentials.json'));
var url = 'private';
casper.start(url + '/user/login', function() {
this.fill('form#login_form', credentials, true);
});
casper.thenOpen(url + '/subscription/config/xebia.com/exchange_mailbox', function() {
this.getElementsInfo('tr td a').forEach(function (node) {
if (node.attributes.nicetitle === "View") {
casper.thenOpen(url + node.attributes.href, function() {
require('fs').write('output', JSON.stringify(this.getElementInfo('div.contentleft').html, 'a'));
});
}
});
});
casper.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment