Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to parse rss-feeds / xml in a shell script

I'd like to parse rss feeds and download podcasts on my ReadyNas which is running 24/7 anyway.

So I'm thinking about having a shell script checking periodically the feeds and spawning wget to download the files.

What is the best way to do the parsing?

Thanks!

like image 673
Oli Avatar asked Jan 14 '09 17:01

Oli


1 Answers

Sometimes a simple one liner with shell standard commands can be enough for this:

 wget -q -O- "http://www.rss-specifications.com/rss-podcast.xml" | grep -o '<enclosure url="[^"]*' | grep -o '[^"]*$' | xargs wget -c

Sure this does not work in every case, but it's often good enough.

like image 145
leo Avatar answered Oct 11 '22 19:10

leo