CasperJS login before Scraping
2017-06-06 本文已影响24人
RoyTien
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);
});