From: Li Chen Date: 2009-02-02T06:40:37+09:00 Subject: Re: How to download all mp3 files from this website? Phlip wrote: > Li Chen wrote: >> Hi all, >> >> I want to download all the mp3 files from this website: >> http://rss.sciam.com/sciam/60secsciencepodcast. >> >> But I cannot see the link to each mp3 file in the source file. I wonder >> how I can find out each link for the mp3 in source file. > > A> What's the relation to the language Ruby here? #Use Ruby script to download a webpage ranging from 15274.html to 15334.html # and here is an example #download a webpage based on an address require 'open-uri' require 'threadlimiter' #address='http://www.qenglish.com/samples/15334.html' #.... #address='http://www.qenglish.com/samples/15274.html' addresses=[] address1='http://www.qenglish.com/samples/' address2='' address3='.html' # create the address (15274..15334) .to_a.each do |i| addresses<<(address1 + i.to_s+ address3) end #download the files addresses.threaded_collect(1)do |a_uri| open(a_uri) do |a_file| f_name=File.basename(a_uri) open(f_name,'wb') do|r_file| a_file.each_line do |a_line| r_file.write a_line end end end end -- Posted via http://www.ruby-forum.com/.