Skip to content

Instantly share code, notes, and snippets.

@gorgogol
Created July 26, 2014 15:50
Show Gist options
  • Save gorgogol/8b1572f08d6c620486dc to your computer and use it in GitHub Desktop.
Save gorgogol/8b1572f08d6c620486dc to your computer and use it in GitHub Desktop.
Returns number of google results for search of given term. (example: casperjs --key=java searchGoogle.js) #casperjs
var casper = require('casper').create({
verbose: true,
logLevel: "debug"
});
var key = casper.cli.options['key'];
var url = 'http://www.google.com';
casper.start(url);
casper.then(function(){
this.fill("form", {'q': key}, true );
});
casper.then(function(){
this.echo(this.fetchText("#resultStats").match(/\d.*\d/));
});
casper.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment