如何记录ruby mechanize post请求?

时间:2013-04-30 23:01:40

标签: ruby logging

我有一个代码

@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”)),一切正常,所以它会出错。 在这种情况下如何记录我的帖子请求是否正确?

0 个答案:

没有答案