CasperJS login before Scraping

Set up CasperJS


var casper = require('casper').create();

Start with login page


casper.start('the url of login page', function() {
  // Login Founction Two
  this.sendKeys('form#id input#email', 'your email');
  this.sendKeys('form#id input#password', 'your password');
  this.click('form#id input[type="submit"]');
});

Wait one second so that server can valid login information


casper.wait(1000, function() {
});

casper.thenOpen('the normal page url', function() {
  this.evaluate(your own method);
});

你可能感兴趣的:(CasperJS login before Scraping)