Skip to content

Instantly share code, notes, and snippets.

@m040601
Created October 14, 2010 09:06
Show Gist options
  • Save m040601/625919 to your computer and use it in GitHub Desktop.
Save m040601/625919 to your computer and use it in GitHub Desktop.
lastfm mp3 down - wget and awk
#!/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