I'd like to download all mp3s from the blog pinchy&friends. I tried the script

for mp3 in "http://www.pinchyandfriends.com/dl.php?mp3=*.mp3"; do
    wget "http://www.pinchyandfriends.com/dl.php?mp3=${mp3}.mp3"
    sleep 5
done

But all that results in is an attempt to download the literal http://www.pinchyandfriends.com/dl.php?mp3=*.mp3. Am I misunderstanding something about the script I wrote and/or is there a better way to do what I'm attempting? Thanks in advance.

有帮助吗?

解决方案

You can't do it this way, you're $mp3 variable is actually: "http://www.pinchyandfriends.com/dl.php?mp3=*.mp3"

You have to solve it this way:

for mp3 in "title1" "title2" "title3"; do
    wget "http://www.pinchyandfriends.com/dl.php?mp3=$mp3.mp3"
    sleep 5
done

You should think how to obtain the mp3 names first.

Edit: Here's Your solution.

 for album in $(wget -q -O- http://www.pinchyandfriends.com/ | egrep -o "/[0-9]+/[^/]+/"); do
     echo $album                                                                 
     dl_uri=$(wget -q -O- "http://www.pinchyandfriends.com$album" | egrep -o '/dl.php[^"]+')                                                                         
     wget "http://www.pinchyandfriends.com$dl_uri"  
 done

This script gets the list of albums from the main page, then goes to the album page to fetch the download uri, and then uses wget to actually get the mp3

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top