2

I want to get an xml content from a url (let's say http://stackoverflow.com). For this I use open uri. When I do

begin
  status = Timeout::timeout(5) {
  getresult = open("http://stackoverflow.com", "UserAgent" => "Ruby-OpenURI").read
}
rescue => e#Timeout::Error => e
  puts e.to_s
end

I get an error that says "can't convert hash into a string". I didn't require any file. Can anyone let me know what am I doing wrong here! I am using Ruby 1.8.7.

Sadiksha Gautam
  • 4,604
  • 6
  • 35
  • 67

0 Answers0