문제

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