Skip to content

Instantly share code, notes, and snippets.

@phil-r
Created April 4, 2018 15:44
Show Gist options
  • Save phil-r/5d015691c622b3dd92655fe97167a10b to your computer and use it in GitHub Desktop.
Save phil-r/5d015691c622b3dd92655fe97167a10b to your computer and use it in GitHub Desktop.
Download all octocat images from octodex
const fs = require("fs");
const request = require("request");
const async = require("async");
// client side
// const list = [];
//
// $("img").each(function(i, el) {
// var _src;
// _src = $(this).data("src");
// if (_src) {
// list.push(_src);
// }
// });
//
// JSON.stringify(list, true, 2);
octocats = [
"snowtocat_final.jpg",
"justicetocat.jpg",
"blacktocats.png",
"saint_nictocat.jpg",
"mona-lovelace.jpg",
"dinotocat.png",
"bannekat.png",
"catstello.png",
"mcefeeline.jpg",
"skatetocat.png",
"bewitchedtocat.jpg",
"inflatocat.png",
"hanukkat.png",
"welcometocat.png",
"filmtocat.png",
"privateinvestocat.jpg",
"gracehoppertocat.jpg",
"gobbleotron.gif",
"jetpacktocat.png",
"minertocat.png",
"mountietocat.png",
"saketocat.png",
"luchadortocat.png",
"saritocat.png",
"topguntocat.png",
"carlostocat.gif",
"grinchtocat.gif",
"maxtocat.gif",
"yaktocat.png",
"steroidtocat.png",
"mummytocat.gif",
"labtocat.png",
"dunetocat.png",
"octoliberty.png",
"femalecodertocat.png",
"daftpunktocat-thomas.gif",
"daftpunktocat-guy.gif",
"foundingfather_v2.png",
"poptocat_v2.png",
"Mardigrastocat.png",
"kimonotocat.png",
"Professortocat_v2.png",
"goretocat.png",
"Robotocat.png",
"motherhubbertocat.png",
"skitchtocat.png",
"gangnamtocat.png",
"droctocat.png",
"spidertocat.png",
"megacat-2.png",
"dodgetocat_v2.png",
"stormtroopocat.png",
"pusheencat.png",
"deckfailcat.png",
"murakamicat.png",
"homercat.png",
"minion.png",
"droidtocat.png",
"octofez.png",
"heisencat.png",
"red-polo.png",
"twenty-percent-cooler-octocat.png",
"momtocat.png",
"front-end-conftocat.png",
"snowoctocat.png",
"electrocat.png",
"codercat.jpg",
"strongbadtocat.png",
"adventure-cat.png",
"doctocat-brown.jpg",
"dojocat.jpg",
"defunktocat.png",
"herme-t-crabb.png",
"saint-nicktocat.jpg",
"orderedlistocat.png",
"thanktocat.png",
"megacat.jpg",
"linktocat.jpg",
"plumber.jpg",
"octotron.jpg",
"baracktocat.jpg",
"octocat-de-los-muertos.jpg",
"grim-repo.jpg",
"father_timeout.jpg",
"waldocat.png",
"hipster-partycat.jpg",
"riddlocat.png",
"visionary.jpg",
"oktobercat.png",
"shoptocat.png",
"nyantocat.gif",
"octdrey-catburn.jpg",
"spectrocat.png",
"bear-cavalry.png",
"andycat.jpg",
"notocat.jpg",
"dodgetocat.jpg",
"cloud.jpg",
"scarletteocat.jpg",
"poptocat.png",
"jenktocat.jpg",
"xtocat.jpg",
"chellocat.jpg",
"cherryontop-o-cat.png",
"supportcat.png",
"collabocats.jpg",
"constructocat2.jpg",
"total-eclipse-of-the-octocat.jpg",
"pacman-ghosts.jpg",
"okal-eltocat.jpg",
"octoclark-kentocat.jpg",
"agendacat.png",
"ironcat.jpg",
"inspectocat.jpg",
"jean-luc-picat.jpg",
"spocktocat.png",
"wilson.jpg",
"swagtocat.png",
"drunktocat.jpg",
"hubot.jpg",
"monroe.jpg",
"trekkie.png",
"octonaut.jpg",
"bouncercat.png",
"founding-father.jpg",
"pythocat.png",
"drupalcat.jpg",
"socialite.jpg",
"setuptocat.jpg",
"repo.png",
"forktocat.jpg",
"benevocats.png",
"scottocat.jpg",
"puppeteer.png",
"octobiwan.jpg",
"class-act.png",
"original.png"
];
download = function(name) {
return function(cb) {
request(`http://octodex.github.com/images/${name}`, cb).pipe(fs.createWriteStream("./octocats/" + name));
};
};
fns = [];
for (j = 0, len = octocats.length; j < len; j++) {
url = octocats[j];
fns.push(download(url));
}
async.parallel(fns, function(err, success) {
console.log("DONE");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment