From: Mike Dalessio Date: 2010-09-13T21:45:39+09:00 Subject: Re: Mechanize file save on generated link --0015175cbaa816b61a049023790b Content-Type: text/plain; charset=ISO-8859-1 On Sun, Sep 12, 2010 at 5:54 PM, Dan Mansfield wrote: > thanks, so my script is now: > .... > invoice_page = agent.get(URL_BILLING) > link = invoice_page.links_with(:href => "/be-portal/downloadPdf") > > File.open('myfile', 'w+') do |file| > file << agent.get_file(link['href']) > end > > results in: > C:/ruby/test.rb:27:in `[]': can't convert String into Integer > (TypeError) > from C:/ruby/test.rb:27:in `block in
' > from C:/ruby/test.rb:26:in `open' > from C:/ruby/test.rb:26:in `
' > > what is the proper method to see the response back from clicking the > link? > links_with returns an array. Try using .first to pick out the first result, so: link = invoice_page.links_with(:href => "/be-portal/downloadPdf").first --0015175cbaa816b61a049023790b--