Saturday, July 16, 2011

How to download multiple songs (files) from a site via wget

This was my long time requirement, ie, whenever I wanted to download songs from any site. I finally found the solution for the same - Thanks to Google.

There is no direct way to do this however, a workaround does exist.

Step1: Using lynx extract all the outgoing links from the html page where the songs are listed.

#lynx -dump "http://www.example.com" | grep -o "http:.*" > file.txt

or if the songs are listed in the same directory and you can identify the path of the directory by hovering over the song links, below would help a lot -
#lynx -dump "http://www.example.com" | grep -o "http://parent/directory/of/song/files/.*" > file.txt

Step2: Cleanup the URLs in file.txt such that it contains only the song URLs

Step3: Use wget, TADA... there you go :-)
#wget -i file.txt


-Jeeva