From: Li Chen Date: 2008-09-11T02:32:55+09:00 Subject: Re: find a button using mechanize Martin DeMello wrote: > It's probably not the wav file, then. Does opening it up in notepad > reveal anything? > > martin The one downloaded directly is a binary file and the one using script is a HTML page. Since I use the following script( by Lex) to download the file I wonder how to fix it. Thanks, Li ################## require "rubygems" require "mechanize" mech = WWW::Mechanize.new mech.user_agent_alias = "Windows IE 6" mech.get("http://www.ask.com/web?qsrc=2352&o=0&l=dir&dm=&q=dictionary") form = nil form = mech.page.forms.select {|form| form.has_field?("aj_text1")}.first if(form == nil) abort "could not find form" end form.aj_text1 = "abacus" new_page = mech.submit(form) wav_link = mech.page.links.select {|link| link.href =~/\.wav$/i}.first puts "downloading #{wav_link.href}" mech.get(wav_link).save_as(File.basename(wav_link.href)) -- Posted via http://www.ruby-forum.com/.