Use wget to download all linked mp3 files from website

6

5

I'm trying to use wget to download the mp3 files from https://musicforprogramming.net/ . As you can see, there is a link to each track page (e.g. https://musicforprogramming.net/?twentythree) from the home page, and a link to the mp3 file on each track page (e.g. https://datashat.net/music_for_programming_23-panda_magic.mp3).

I thought this command would download all of the mp3 files for me:

wget -r --no-parent --accept mp3,MP3 -nd https://musicforprogramming.net/

But it seems to ignore them, and only scan through the html pages without downloading any.

What should I do to have wget download all ~50 mp3 files that are linked there?

Hugh Grigg 葛修远

Posted 2018-05-22T12:22:24.773

Reputation: 205

Answers

7

I believe by default wget will stick to the current domain only. So if the files were hosted on musicforprogramming.net it'd download them.

Use -D to pass a list of accepted domains:

(As pointed out in the comments by Hugh Grigg, you also need --span-hosts

wget -r --no-parent --accept mp3,MP3 -nd -D datashat.net,musicforprogramming.net --span-hosts https://musicforprogramming.net/

djsmiley2k TMW

Posted 2018-05-22T12:22:24.773

Reputation: 5 937

Note, this still doesn't technically work, because the site appears to be doing something clever to block downloaders. – djsmiley2k TMW – 2018-05-22T13:05:09.137

It seems to require a combination of this and --span-hosts. – Hugh Grigg 葛修远 – 2018-05-22T13:23:55.117

@HughGrigg葛修远 thanks, that works so I'll update my answer!. – djsmiley2k TMW – 2018-05-22T15:06:59.953