Skip to content

Instantly share code, notes, and snippets.

@flaviosilveira
Created March 16, 2017 01:38
Show Gist options
  • Save flaviosilveira/457ae829e07b4da25226f24e73596c8b to your computer and use it in GitHub Desktop.
Save flaviosilveira/457ae829e07b4da25226f24e73596c8b to your computer and use it in GitHub Desktop.
CasperJS Script to grab google popular time
// Inicia Casper, simulando User Agent
var casper = require('casper').create({
pageSettings: {
userAgent: 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36'
}
}
);
// Vai até o endereço
casper.start('https://www.google.com.br/search?q=tuk%20tuk%20curitiba&*', function() {
// Pega título
this.echo(this.getTitle());
// Tira um print screen
this.capture('google.png');
// Retorna todo o HTML da página, incluindo o popular Time.
this.echo(this.getHTML());
});
// Roda o casper
casper.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment