使用 Mechanize 时收到 'deprecated' 警告
Getting 'deprecated' warnings whilst using Mechanize
我 运行 使用 Ruby 机械化的所有内容都会收到这些警告。
mechanize/cookie will be deprecated. Please migrate to the http-cookie APIs.
mechanize/cookie_jar will be deprecated. Please migrate to the http-cookie APIs.
我似乎找不到任何关于如何更改我的代码以清除这些错误的文档。
#!/usr/bin/ruby -w
require 'rubygems'
require 'mechanize'
a = Mechanize.new { |agent|
agent.user_agent_alias = 'Mac Safari'
}
title = a.get('http://google.com').title
puts title
我想我需要安装满足这些要求的东西?
请迁移到 http-cookie API。
编辑 1
安装 gem install http-cookie
对这些警告没有影响。我不知道 Mechanize 是否知道使用 http-cookie
或者它是否只是使用了不正确的 cookie_jar
。
每当我遇到此类错误时,我都会执行以下操作:
bundle list my_gem
cd <DIR>
ag 'Please migrate to'
这通常会指出问题的根源
编辑:转到 http-cookies github 的注释表明它是从 Mechanize 中提取的:https://github.com/sparklemotion/http-cookie
我 运行 使用 Ruby 机械化的所有内容都会收到这些警告。
mechanize/cookie will be deprecated. Please migrate to the http-cookie APIs.
mechanize/cookie_jar will be deprecated. Please migrate to the http-cookie APIs.
我似乎找不到任何关于如何更改我的代码以清除这些错误的文档。
#!/usr/bin/ruby -w
require 'rubygems'
require 'mechanize'
a = Mechanize.new { |agent|
agent.user_agent_alias = 'Mac Safari'
}
title = a.get('http://google.com').title
puts title
我想我需要安装满足这些要求的东西?
请迁移到 http-cookie API。
编辑 1
安装 gem install http-cookie
对这些警告没有影响。我不知道 Mechanize 是否知道使用 http-cookie
或者它是否只是使用了不正确的 cookie_jar
。
每当我遇到此类错误时,我都会执行以下操作:
bundle list my_gem
cd <DIR>
ag 'Please migrate to'
这通常会指出问题的根源
编辑:转到 http-cookies github 的注释表明它是从 Mechanize 中提取的:https://github.com/sparklemotion/http-cookie