Skip to content

Instantly share code, notes, and snippets.

@ssddi456
Last active December 21, 2015 22:38
Show Gist options
  • Save ssddi456/6376124 to your computer and use it in GitHub Desktop.
Save ssddi456/6376124 to your computer and use it in GitHub Desktop.
get google doodle list
var _ = require('underscore');
var request = require('request');
var async = require('async');
console.log('/*');
var checkApi = _.template('http://www.google.com/doodles/json/<%=year%>/<%=month%>');
async.reduce(_.range(1998,2013+1),[],function( cache ,year, yeardone) {
console.log( 'year', year );
var fullyear = [];
async.eachLimit(_.range(1,12+1), 5, function( month, monthdone ) {
console.log( 'month', month );
console.log( checkApi({year:year,month:month}) );
request(checkApi({year:year,month:month}),function(err,req,body){
monthdone(err,err || (fullyear = _.union(fullyear, JSON.parse(body))) );
});
},function(err ){
yeardone(err, err || _.union(cache,fullyear));
});
},function(err, finish){
console.log('*/');
console.log( finish );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment