Ruby open-uri redirect forbidden

前端 未结 3 1114
耶瑟儿~
耶瑟儿~ 2020-12-15 15:56

I have this simple html parser(for learning purposes) that I have been working on.:

require \'open-uri\'
puts \"Enter URL to parse HTML: \"
url = gets.chomp
         


        
3条回答
  •  南笙
    南笙 (楼主)
    2020-12-15 16:37

    Ruby 2.4 fixed upgrade redirects (from http -> https) in open-uri, so now:

    RUBY_VERSION
    => "2.4.2"
    
    require 'open-uri'
    => true
    
    open('http://twitter.com')
    => #
    

    Source: http://blog.bigbinary.com/2017/03/02/open-uri-in-ruby-2-4-allows-http-to-https-redirection.html

提交回复
热议问题