Ruby HTTPclient:不建议在位置标头中使用相对URI

时间:2018-06-30 11:48:17

标签: ruby httpclient

我要抓取这样的网站:

 url = 'https://www.example.com/projects/search?scope=projects'
 content = @clnt.get_content(url,nil,CONF.header)
 doc = Nokogiri::HTML(content)

但是我收到以下消息:

/projects/search?scope=projects: a relative URI in location header which is not recommended
'The field value consists of a single absolute URI' in HTTP spec
Cookie#domain returns dot-less domain name now. Use Cookie#dot_domain if you need "." at the beginning.

有人知道如何处理吗?

1 个答案:

答案 0 :(得分:0)

据我所知,get_content的工作方式与get类似,但也可以遵循重定向。在这种情况下,重定向是通过相对URL完成的,因此gem会产生警告。 See the source code