[英]Mechanise Post headers
如何查看机械化后发请求传递的标题?
换句话说,如果我使用a.post网址,则希望查看在发布请求中发送的请求标头。
您可以附加pre_connect_hook
并在其中检查请求标头。
require 'mechanize'
agent = Mechanize.new do |a|
a.pre_connect_hooks << lambda do |a, request|
p request.to_hash # convert the request to header hash and dump it
end
end
agent.post 'http://stackoverflow.com'
# {"accept-encoding"=>["gzip,deflate,identity"], "accept"=>["*/*"], ... }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.