So, yesterday NASA published a collection of sounds from historic spaceflights and current missions.
You can check them out here.

Well, I noticed there was no ‘download ALL’ button there, and because most links at a time were hidden by means of javascript my normal tools didn’t really work.

SO! It was time for some scripting!

First, I opened up the FireBug console [link] and tried to see if jQuery was used on the page.
Of course it was, BUT, with a twist. The $ shortcut was assigned to another library. No matter, I can still use jQuery ‘s full name.

So, let’s get a list with all the links to .mp3 files:


which means, get all anchor elements whose href attribute ends with “.mp3”

What should we do to them then?
Keeping it simple, let’s just print the href attribute for each of them on the console. So we go:


Pretty straightforward. It’s a one-liner, but I indented here for clarity.

You’ll notice that at the end of the links, we also get an array of all the elements. Well, that’s because our whole statement also returns the collection.
So let’s copy-paste the links to a text file, let’s name it ‘in’.

445945....min.js (line 30)
445945....min.js (line 30)
445945....min.js (line 30)
445945....min.js (line 30)

Oh bummer! We also got a lot of lines like “445945….min.js (line 30)” on them. Not really a problem, let’s crunch it up with python for the geek-out factor:
I ran this:

with open('in') as f:
    lines = f.readlines()
final = [line for line in lines if line.endswith('.mp3\n')]
with open('out', 'w') as f:

Again, we only keep that lines that end with ‘.mp3’ (and the newline) as relevant.
What should we do with our list file now you ask? But of course use wget.
We want wget to grab all our .mp3s from the list in the file, prepending ‘’, as the urls are relative
Here it is:

wget -i b -B

And voila! Here is our collection of NASA mp3s for our geeky pleasure!