Hi, I''m having a issue when attempt to read this page: http://www.treasury.gov/resource-center/sanctions/SDN-List/Pages/default.aspx and get the following error: C:/Ruby187/Ruby1.8.7/lib/ruby/1.8/open-uri.rb:277:in `open_http'': 500 Internal Server Error (OpenURI::HTTPError) from C:/Ruby187/Ruby1.8.7/lib/ruby/1.8/open-uri.rb:616:in `buffer_open'' from C:/Ruby187/Ruby1.8.7/lib/ruby/1.8/open-uri.rb:164:in `open_loop'' from C:/Ruby187/Ruby1.8.7/lib/ruby/1.8/open-uri.rb:162:in `catch'' from C:/Ruby187/Ruby1.8.7/lib/ruby/1.8/open-uri.rb:162:in `open_loop'' from C:/Ruby187/Ruby1.8.7/lib/ruby/1.8/open-uri.rb:132:in `open_uri'' from C:/Ruby187/Ruby1.8.7/lib/ruby/1.8/open-uri.rb:518:in `open'' from C:/Ruby187/Ruby1.8.7/lib/ruby/1.8/open-uri.rb:30:in `open'' from prueba_fecha.rb:11 This is the code I''m using url "http://www.treasury.gov/resource-center/sanctions/SDN-List/Pages/default.aspx" doc = Hpricot(open(url)) Somebody can help me with it? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Wed, Nov 30, 2011 at 10:29 AM, art tav <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi, I''m having a issue when attempt to read this page: > > http://www.treasury.gov/resource-center/sanctions/SDN-List/Pages/default.aspx> C:/Ruby187/Ruby1.8.7/lib/ruby/1.8/open-uri.rb:277:in `open_http'': 500 > Internal Server Error (OpenURI::HTTPError)Love it. Apparently that server is rather picky about the requests it''s willing to service :-) Thank you, Treasury Department! Anyway, try:>> doc = Hpricot(open(url, "User-Agent" => "MSIE"))=> #<Hpricot::Doc "\r\n" {doctype "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \... Note: this also works :-)>> doc = Hpricot(open(url, "User-Agent" => "Zombies from Space"))(A look through the open-uri docs will be useful for future reference.) FWIW, -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org http://about.me/hassanschroeder twitter: @hassan -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Ohh nice thanks for the help :) -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.