require 'net/http'
def get_web_document(url)
uri = uri.parse(url)
response = net::http.get_response(uri)
case response
when net::httpsuccess:
return response.body
when net::httpredirection:
return get_web_document(response['location'])
else
return nil
end
end
puts get_web_document('http://www.51sjk.com/upload/articles/1/0/321/321460_20220812163042575.txt')
puts get_web_document('http://www.rubyinside.com/non-existent')
用户登录
还没有账号?立即注册
用户注册
投稿取消
| 文章分类: |
|
还能输入300字
上传中....
隔壁王中王啊