0

I have a web page. On it are a list of links. Each link downloads a binary (zipped) file and I would like to download them with ruby. For the first part I use mechanize but the part I have trouble with is net:http

So far I have:

agent.page.links_with(:href => /ViewSample/).map {|link| link.click
agent.page.links_with(:href => /DownloadFile/).each do |link|
link=t+link.uri.to_s
uri = URI(link)
puts uri.class
File.open("downloaded_file", "wb") do |f|
    f << Net::HTTP.get(uri)

end
end
}

At the moment there are no errors but nothing gets downloaded.

I know the individual uri's are correct as I've checked them in with puts uri after uri = URI(link)

Sebastian Zeki
  • 6,690
  • 11
  • 60
  • 125
  • No its not. I am asking specifically about downloading all the files from a web page. That question asks about one file – Sebastian Zeki Dec 31 '15 at 18:27
  • http://ruby-doc.org/core-2.2.0/Array.html#method-i-each – Kristján Dec 31 '15 at 18:29
  • Please provide answers rather than a generic link – Sebastian Zeki Dec 31 '15 at 18:31
  • 1
    It would help if you were able to provide an example that can be copy and pasted for testing. – Mike S Dec 31 '15 at 18:44
  • 1
    "I am asking specifically about downloading all the files from a web page. That question asks about one file". Perhaps you should think about the problem you're dealing with. You want to download a file. Then you want to download another file. Then another file. How do you do all files on the page? By doing one at a time. We are not here to write full applications for you. We help you understand how to fix the problem in code, or fix your thinking about how to fix the problem. – the Tin Man Dec 31 '15 at 19:03
  • I'm not asking for a full application. I'm just asking how to download a series of uris. That link doesn't address that question. I'm not sure my thinking needs correcting and perhaps if you find the question irritating you should just not answer it and let others help. – Sebastian Zeki Dec 31 '15 at 23:39

0 Answers0