Commit f5d21fc3 f5d21fc39013f95ba59b644c59cae6c43e27f0d4 by Nicolas Perriault

fixed obsolete use of Casper.extend in samples

1 parent d433cf8c
......@@ -10,15 +10,13 @@ Usage:
winner is "nicolas" with 69600000 results
###
CasperClass = require('casper').Casper
casper = require('casper').create verbose: true
CasperClass.extend
fetchScore: -> @evaluate ->
casper.fetchScore = ->
@evaluate ->
result = document.querySelector('#resultStats').innerText
~~(/Environ ([0-9\s]{1,}).*/.exec(result)[1].replace(/\s/g, ''))
casper = new CasperClass verbose: true
terms = casper.cli.args # terms are passed through command-line arguments
if terms.length < 3
......
......@@ -9,21 +9,17 @@
* borris: 2370000
* winner is "nicolas" with 69600000 results
*/
var CasperClass = require('casper').Casper;
CasperClass.extend({
fetchScore: function() {
return this.evaluate(function() {
var result = document.querySelector('#resultStats').innerText;
return ~~(/Environ ([0-9\s]{1,}).*/.exec(result)[1].replace(/\s/g, ''));
});
}
});
var casper = new CasperClass({
var casper = new require('casper').create({
verbose: true
}), terms = casper.cli.args, scores = [], i = 0;
casper.fetchScore = function() {
return this.evaluate(function() {
var result = document.querySelector('#resultStats').innerText;
return ~~(/Environ ([0-9\s]{1,}).*/.exec(result)[1].replace(/\s/g, ''));
});
};
if (terms.length < 2) {
casper.echo('Usage: casperjs googlematch.js term1, term2 [, term3]...').exit();
}
......