Martin DeMello wrote:
> On Wed, Sep 10, 2008 at 10:32 AM, Li Chen <chen_li3 / yahoo.com> wrote:
>> puts "downloading #{wav_link.href}"
>> mech.get(wav_link).save_as(File.basename(wav_link.href))
> 
> wgetting the href displayed works, so I'm guessing it's the call to
> mech.get that's failing. there's probably a cleaner way to do it via
> mechanize, but this works:
> 
> File.open(File.basename(wav_link.href), 'w') {|f|
> f.puts(mech.get_file(wav_link.href))}
> 
> martin


Hi Martin,

Now the wav file can be played properly.

I have another question: the file downloaded via script is 9.36 kb and 
the one from browser is 9.35kb. What causes the discrepancy?

Another question: I also need to retrieve the definition of the word 
corresponding to the wav file from the same page. Can Mechanize do that?
I plan to use Hpricot to extract the info. I wonder if you or others 
have any suggestions.

Thank you very much,

Li
-- 
Posted via http://www.ruby-forum.com/.