Created
April 15, 2015 17:33
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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