Create a gist now

Instantly share code, notes, and snippets.

@workmajj /apollo.js
Last active Dec 20, 2015

What would you like to do?
Steps for bulk downloading NASA Apollo images in the public domain.
// 0. open url: http://www.apolloarchive.com/apollo_gallery.html
// (n.b. all images to be downloaded are in the public domain)
// 1. install jquery by running this snippet in the console:
var s = document.createElement('script');
s.src = 'https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js';
(document.getElementsByTagName('head')[0] ||
document.getElementsByTagName('body')[0]).appendChild(s);
// 2. click on an index page and run this to generate a list of image links:
var urlA = [];
$('a', frames.itemlist.document.getElementsByTagName('html')).each(function() {
var ids = this.href.match(/disptn\('(\d+)','(.+)'\)/);
if (ids) {
urlA.push('http://www.apolloarchive.com/apg_thumbnail-test.php?ptr=' +
ids[1] + "&imageID=" + ids[2]);
}
});
var dl = window.setInterval(function() {
if (!urlA.length) {
window.clearInterval(dl);
return;
}
$.get(urlA.pop()).done(function(d) {
console.log($('table', d).find('a').last().get(0).href); // last url is best res
});
}, 2000); // site-enforced rate limit
// 3. paste list of links into a file named images.txt and run:
// $ wget -i images.txt
// (you may need to install wget via `brew install wget` first;
// if you don't have homebrew installed, get it here: http://brew.sh/)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment