Skip to content

Instantly share code, notes, and snippets.

@quanengineering
Last active March 15, 2016 19:05
Show Gist options
  • Save quanengineering/1611f70b16d17c35fbaa to your computer and use it in GitHub Desktop.
Save quanengineering/1611f70b16d17c35fbaa to your computer and use it in GitHub Desktop.
How to crawl with casperjs (bypass login page)
var casper = require('casper').create();
var url = 'https://www.getnewsmart.com/articles/80250-xiaomi-keeps-sights-on-india-has-no-ipo-timetable';
casper.start(url, function() {
this.echo(this.getTitle());
})
casper.waitFor(function check() {
return true;
}, function then() {
this.click("#pjax-container > div.container-top-part > div > div > a.js-signin.btn.user-auth-control_btn.-login");
});
casper.waitForSelector('#js-sign-in', function() {
this.fill('#sign_in_form', { 'user[email]': '[email protected]', 'user[password]':'b1615734' }, false);
this.click('#sign_in_form > input.btn.btn-sign-in');
})
casper.waitForSelector('.logout', function() {
this.open(url);
});
casper.waitForSelector('#js-article', function() {
var text = this.evaluate(function() {
return __utils__.findOne('#js-article').textContent;
});
this.echo(text);
});
casper.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment