require 'open-uri'
open("http://www.baidu.com") do |f|
f.each_line {|line| p line}
puts f.base_uri
puts f.content_type
puts f.charset
puts f.content_encoding
puts f.last_modified
end
运行结果错误:
C:/Ruby193/lib/ruby/1.9.1/net/http.rb:762:in `initialize': A connection attempt
failed because the connected party did not properly respond after a period of ti
me, or established connection failed because connected host has failed to respon
d. - connect(2) (Errno::ETIMEDOUT)