1

我有一个代码

@agent = Mechanize.new do |a| 
  a.log = Logger.new(File.open("logs/parser.log", "w")),
  a.ssl_version, 
  a.verify_mode = 'SSLv3', 
  OpenSSL::SSL::VERIFY_NONE, 
  a.user_agent_alias = 'Windows Mozilla'
end
def authorization
  ajax_headers = { 'X-Requested-With' => 'XMLHttpRequest', 'Content-Type' => 'application/x-www-form-urlencoded; charset=UTF-8',
   'Accept' => 'application/json, text/javascript, */*; q=0.01', 'Accept-Encoding' => 'gzip, deflate',
   'Referer' => 'http://mysite.ru/' }
  params = {'login' => 'name', 'domain' => 'mail.ru', 'password' => 'pass'}
  response = @agent.post( 'http://mydomain', params, ajax_headers)
end

此代码案例错误

C:/Ruby193/lib/ruby/gems/1.9.1/gems/mechanize-2.6.0/lib/mechanize.rb:1264:in `post_form': undefined method `debug' for
<Array:0x2d20610> (NoMethodError)

如果没有 a.log = Logger.new(File.open("logs/parser.log", "w")),一切正常,因此会出现错误。在这种情况下如何正确记录我的发布请求?

4

0 回答 0