submit_form = agent.get("http://sample.com/NewTask.aspx").form("aspnetForm") do |f|
f["ctl00$ContentPlaceHolder1$txtNumber"] = "1234",
f["ctl00$ContentPlaceHolder1$cmbText"] = "test",
f["ctl00$ContentPlaceHolder1$FUpload$fu"] = "",
f["ctl00$ContentPlaceHolder1$btn"] = "test"
f.submit(f.button_with(:name => "ctl00$ContentPlaceHolder1$btnOK"))
end这是我使用Ruby的机械化库为表单自动提交编写的代码,它通过Mechanize::ResponseCodeError返回,如下所示。我真的没有在我的代码中看到任何错误,任何人可以让我知道这是代码错误还是服务器端的什么(比如服务器阻止表单自动提交)?
C:/Ruby193/lib/ruby/gems/1.9.1/gems/mechanize-2.4/lib/mechanize/http/agent.rb:29 1:in fetch': 500 => Net::HTTPInternalServerError for http://sample.com/NewTask.aspx -- unhandled response (Mechanize::ResponseCodeError) from C:/Ruby193/lib/ruby/gems/1.9.1/gems/mechanize-2.4/lib/mechanize.rb:1207:inpost_form‘from C:/Ruby193/lib/ruby/gems/1.9.1/gems/mechanize-2.4/lib/mechanize.rb:515:in submit' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/mechanize-2.4/lib/mechanize/form.rb:178:insubmit’from auto_post.rb:27:in block in <main>' from (eval):23:inform_with‘from auto_post.rb:13:in `’
发布于 2012-05-09 17:25:20
您需要通过像fiddler或charles这样的调试代理进行代理:
agent.set_proxy 'localhost', 8888然后以类似的方式代理您的浏览器,并比较请求
https://stackoverflow.com/questions/10512505
复制相似问题