Skip to content

Instantly share code, notes, and snippets.

Created March 16, 2015 18:35
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 anonymous/c87b335e1cf09a0e4443 to your computer and use it in GitHub Desktop.
Save anonymous/c87b335e1cf09a0e4443 to your computer and use it in GitHub Desktop.
var casper = require('casper').create();
var fs = require('fs');
casper.start('http://google.com.au/', function() {
});
casper.then(function() {
f = {};
f['q'] = 'Jn Solutions';
this.fill('form[action="/search"]', f, true);
});
function getLinks() {
var links = document.querySelectorAll('h3.r a');
return Array.prototype.map.call(links, function(e) {
return (e.getAttribute('href') + '\r\n');
});
}
casper.then(function() {
this.click("td.b a");
this.waitForSelector("#ires", function() {
var links = this.evaluate(getLinks);
this.echo(links);
}, function() {
this.die("Something went wrong")
}, 4000);
});
casper.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment