我不知道如何使用 open-uri 和事件代理从 URL 下载数据。
我使用了这段代码:
proxy = Net::HTTP::Proxy("??????????????????????")
proxy.start('http://www.example.com') { |http|
puts open(strURL).read
}
但 Ruby 返回错误:c:/Ruby192/lib/ruby/1.9.1/net/http.rb:644:in `initialize': A connection attempt failed because the connected party did not properly respond after a period of时间,或建立的连接失败,因为连接的主机未能响应。 - 连接(2)(错误号::ETIMEDOUT)
怎么了?(我不想使用 HTTP)(
最佳答案
试试这个:
require 'open-uri'
p = open('http://www.example.com',
proxy: URI.parse("http://190.72.158.80:8080")
)
关于Ruby 通过代理打开 uri 下载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8656964/