Today DigitalOcean.com will be reaching a million droplets created. The user who spins the millionth droplet and sends a tweet will receive 10.000$ in hosting credit!
But I don’t want to waste time refreshing the page, nor come back and see the million has been reached. So I made a small script with node.js to email me every 1000 droplets =)
This is the basic scraping part of the script, just for fun haha
var request = require('request');
var cheerio = require('cheerio');
var url = 'https://digitalocean.com/';
request(url, function(err, resp, body) {
if (err)
throw err;
$ = cheerio.load(body);
//web scraping
var digits = [];
var digit;
$('.servers_launched .count').each(function() {
digit = parseInt($(this).html(),10);
if (!isNaN(digit)) {
digits.push(digit);
}
});
//now we have the array of digits, translate it into a number
var droplets = 0;
for (var i=0; i<digits.length; i++) {
droplets += (digits[i]*Math.pow(10,digits.length-1-i));
}
console.log(droplets);
});
Enjoy, and good luck!
If you think my content is worth it you can
Buy me a Ko-fi