1

I am trying to use open-uri with Nokogiri

class Script

  require 'nokogiri'
  require 'open-uri'

  open("http://www.ruby-lang.org/") {|f|
    f.each_line {|line| p line}
  }

end

It is timing out with the following error

   in `initialize': execution expired (Net::OpenTimeout)

Any idea why this is happening?

chickenman
  • 728
  • 2
  • 9
  • 29

1 Answers1

0

The page you try to retrieve take time-out. It could be the slow response of the server which can be adjusted like below, or the site down.

            url_object = open(url,  "ssl_verify_mode"=>0, "allow_redirections"=>:safe, "read_timeout"=>Max_http_timeout/1000)

Refer to the doc for more explanation: https://docs.ruby-lang.org/en/2.0.0/OpenURI/OpenRead.html

sam
  • 122
  • 7