Skip to content

Instantly share code, notes, and snippets.

Last active Oct 11, 2015
What would you like to do?
Assaf Arkin Date Challenge
// see results at
var http=require('http');
var fs=require('fs');
// read the file and make a list of the hostnames
var list=fs.readFileSync('hostnames.txt').toString().split('\r\n');
// get from one host and process it
function get(a,i) {
if (i >= a.length) {
// DEBUG console.log('date not found');
// get the host, trim it left and right in case the file has whitespace
var host = a[i].trimLeft().trimRight();
var url = "http://"+host+"/";
var next = i+1;
// get the host
http.get(url,function(res) {
if ( {
// date found, print it and quit
// DEBUG console.log(url);
var d =new Date(;
else {
// result did not have a date, get next host
// DEBUG console.log('no date : ' + url);
}).on('error',function(e) {
// host not found or has no web server, ignore it and get the next one
// DEBUG console.log('no server : ' + url);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment