NASA’s Astronomy Picture of the Day archive is a packed with awe-inspiring, high-resolution images of space that, incidentally, work great as desktop wallpapers. But NASA doesn’t offer an easy way to grab everything. Command-line tool wget to the rescue!
A little backstory: My wife is a graphic designer working on a project related to the Griffith Park Observatory here in Los Angeles. She was looking for high-res images of space, and I knew Nasa’s APOD archive was full of great images—but grabbing them all isn’t easy, and clicking through the archive is tedious. So I turned to wget, a cross-platform command line tool.
Windows users, you can grab wget from here; Mac users, here’s a good one for you. (Follow the installation instructions in the download.) Linux users should have it installed by default. Assuming you’ve got wget installed, open your command line, then cd to a folder you want to store them in (I’ve got mine in a folder on my capacious Media drive called wgot. The command for downloading the archives is simple:
wget -r -l2 -t1 -nd -N -np -w2 -A.jpg -erobots=off http://apod.nasa.gov/apod/archivepix.html
This command will crawl the archive page, follow any links, and eventually start downloading only the JPG files in the domain. The -w2 option adds a two-second wait between each ping—something I didn’t include when I did it, but… I also don’t want us to absolutely kill their servers, so hopefully that will help.
Everything downloaded takes up about 2.64GB on my drive, and you’ll end up with a few low-quality dupes of the higher quality stuff, but you can easily sort by size and get rid of some of the lower resolution stuff. I’m a wget dabbler, so if you’ve got any improvements, let’s hear them in the comments.