ruby - Ruby HTTPclient:不推荐使用位置标头中的相对 URI
问题描述
我想抓取这样的网站:
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.
有谁知道如何处理它?
解决方案
据我所知,实现的get_content
工作方式类似于get
但也允许遵循重定向。在这种情况下,重定向是通过相对 URL 完成的,因此 gem 会产生警告。查看源代码
推荐阅读
- javascript - 从数组合并到对象后的Javascript
- matlab - 来自单元格的 Matlab 图例,用于使用 for 循环创建的绘图
- visual-studio - Visual Studio 2019 运行时异常(HRESULT 异常:0x80070490)
- jquery - youtube 自动播放 - 在 iframe 在 DOM 内移动后防止再次启动视频
- android - Android 日历:使用股票日历或为自己的应用创建另一个日历的最佳实践?
- java - 检查字符串是否包含所有唯一字符
- php - 设置会话 Cookie 过期
- unit-testing - 如何模拟脚本中使用的 groovy 类?
- go - 在 Go 中应该如何设置单例状态?(或者,为什么这不起作用?)
- mysql - 在 Laravel 的查询构建器中使用复杂的 whereIn