Skip to content

Instantly share code, notes, and snippets.

@hmert
Forked from m040601/mygist-1
Created December 8, 2010 22:12
Show Gist options
  • Save hmert/734007 to your computer and use it in GitHub Desktop.
Save hmert/734007 to your computer and use it in GitHub Desktop.
#!/bin/bash
url='http://www.last.fm/music/+free-music-downloads?page=1'
num=$(wget -O- -q "$url" | awk -vRS="</[aA]>" '/class=\"lastpage\"/ {gsub(/.*>/,""); print}')
for((i=1;i<=$num;i++))
do
url="http://www.last.fm/music/+free-music-downloads?page=$i"
wget -O- -q $url | awk 'BEGIN{ RS="</[aA]>" }
/http:\/\/freedownloads.last/{
gsub(/.*href=[\047\042]/,"")
gsub(/\042><span>.*/,"")
print
}'
done | while read -r URL
do
echo wget "$URL"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment