Skip to content

Instantly share code, notes, and snippets.

@mackenziestarr
Created April 15, 2015 17:33
Show Gist options
  • Save mackenziestarr/879b0bb9d8ca81001e4a to your computer and use it in GitHub Desktop.
Save mackenziestarr/879b0bb9d8ca81001e4a to your computer and use it in GitHub Desktop.
Try to run ad impressions in DFP with casperjs, doesn't work. Cool idea.
var casper = require('casper').create(), url, count;
var system = require('system');
if (! casper.cli.has(0)){
casper.echo('usage: run-ad-impressions.js <url> <number>');
}
url = casper.cli.get(0);
count = casper.cli.get(1);
casper.start(url);
casper.then(function() {
runImpression(url, count);
});
casper.run();
function runImpression(url, count){
casper.open(url).then(function(){
casper.wait(3000, function(){
system.stdout.write('.');
if (count != 0){
count = count - 1;
casper.then(function() {
runImpression(url, count);
});
} else {
system.stdout.writeLine('');
casper.echo('ad impressions recorded. check dfp in ~30 minutes');
casper.exit();
}
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment