http://doc.okkez.net/static/191/library/net=2fhttp.html
Net::HTTP.new()してget()しただけではリダイレクトには対応できてないのですね。
良く考えてみればそりゃそうか。
require 'net/http'
require 'uri'
def fetch(uri_str, limit = 10)
# You should choose better exception.
raise ArgumentError, 'HTTP redirect too deep' if limit == 0
response = Net::HTTP.get_response(URI.parse(uri_str))
case response
when Net::HTTPSuccess
response
when Net::HTTPRedirection
fetch(response['location'], limit - 1)
else
response.value
end
end
print fetch('http://www.example.org')