Linux – Use wget to download all linked mp3 files from website

downloadlinuxmp3wget

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?

Best Answer

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/

Related Question