Skip to content

Instantly share code, notes, and snippets.

@izolate
Last active August 29, 2015 14:01
Show Gist options
  • Save izolate/2074f8d025270d55e96a to your computer and use it in GitHub Desktop.
Save izolate/2074f8d025270d55e96a to your computer and use it in GitHub Desktop.
/**
* Requirements: Node.js, npm
* $ npm install request-json
*/
request = require('request-json');
var client = request.newClient('http://letsrevolutionizetesting.com');
var ids = [];
client.get('challenge', function(err, res, body) {
ids.push( body.follow.replace(/\D/g,'') );
var get_next = function(id) {
client.get('challenge?id=' + id, function(err, res, body) {
// still following the trail?
if (body.follow) {
var follow = body.follow.replace(/\D/g, '');
ids.push(follow);
if (ids.indexOf(follow) != -1) {
get_next(last_id());
}
}
// success, we've reached the end!
else {
console.log('IDs collected: %d', ids.length);
console.log(body.message);
}
});
};
// get the IDs!
console.log('Retrieving IDs...');
get_next(last_id());
});
function last_id() {
return ids[ids.length-1];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment