You'll need to install CasperJS for this to work, which should also install PhantomJS as a dependency, assuming you use Homebrew.

First, make sure your brew is up to date:

$ brew update

Then install CasperJS like so:

$ brew install casperjs --devel

This will install the developer release, which is 1.1. as of this writing. This is required if you already have PhantomJS 1.9.x installed, as CasperJS 1.0.x is not compatible with newer versions of PhantomJS.

After that is installed, you'll need to copy the code below into a js file, perhaps something like 20js.js:

var casper = require('casper').create(); var prizes = {};
var pp = function() {
  for (var key in prizes) {
    if (prizes.hasOwnProperty(key)) { this.echo(key + prizes[key]); }
var getPrizes = function() {
  return $('.challenge-listing .prizes .value').map(function(index, element) {
    var text = element.textContent;
    return { d: text[0], v: parseInt(text.slice(1).replace(/[^0-9]/, '')) };
var addPrize = function(p) { prizes[p.d] = (prizes[p.d] || 0) + p.v; };
var getNextPageLink = function() { return $('a.next_page').get(0); };
var sp = function() {
  var pv = this.evaluate(getPrizes); var npl = this.evaluate(getNextPageLink);, addPrize);
  if (npl) { this.thenOpen(npl.href, sp); } else { this.then(pp); }
casper.start("", sp).run();

After you've done so, you can run the program via casperjs 20js.js, which will output the amount of cash prizes available on ChallengePost at the current time, broken out by denomination, something like:



This is a simple command line JavaScript program that scrapes the challenge discovery page of ChallengePost to find the total amount of cash prizes available for upcoming challenges.

When writing this program, I had many ideas of what this could be. I was hoping to break the amount of money available out by date, to create a sort of timeline/graph of prizes available. The hope was that it could be turned into a site that would allow people to make an income off of winning challenges/hackathons. I quickly realized that 20 lines is way less than I thought, so literally the only thing it does is print the total amount of money available.

This program is not smart enough to take into consideration things like the fact that you can really only be at one hackathon at a time, or that you likely won't win every prize for every challenge you enter. It's strictly the total amount of prizes available.

Share this project: