2

I was thinking in a way to get .mp3 files from a html page, manually i did get using wget

wget http://www.podcastfrancaisfacile.com/wp-content/uploads/files/question-prix.mp3

So, i try this for an automatic way to get all mp3 file

grep -i -E -o "content="http://www.podcastfrancaisfacile.com/wp-content/uploads/files/*.mp3" "$thread" | sed 's/ /_/g' - > "$names"

where "$thread" is the name of the html file, "$names" is the list of filenames as output.

And

sed -ne 's/.*\(http[^"]*\).*/\1/p' < "$thread"

related

Bash script to extract some information from Ebay HTML pages

How can I use awk to extract URL's from a HTML file?

bash - extract filenames from html file containing multiple links

2

The following script will download every .mp3 link in the HTML file or URL contained in the variable $thread. It makes use of lynx -dump -listonly, which is one of the easiest and most convenient ways for a shell script to extract a list of URLs from a HTML file or URL.

The script requires you to know the URL for the index page which lists the .mp3 files. Or the filename containing an already-downloaded copy of that page.

You didn't mention what that index URL was, so i've just used the bogus http://www.podcastfrancaisfacile.com/mp3-list.html as an example. Replace with the correct URL or filename.

#! /bin/bash

thread='http://www.podcastfrancaisfacile.com/mp3-list.html'
#thread='mp3-list.html'

while IFS= read -r url ; do
  wget "$url"
done < <(lynx -dump -listonly "$thread" | awk '/\.mp3$/ {print $2}')
0

You can use wget's recursive retrieval options. For example:

$ wget \
    -e robots=off \
    --accept '*.mp3' \
    --level=1 \
    --recursive \
    --no-directories \
    "${thread}"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.