gpt4 book ai didi

Ruby 表单自动提交 Mechanize::ResponseCodeError

转载 作者:行者123 更新时间:2023-12-03 07:55:19 25 4
gpt4 key购买 nike

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 库为表单自动提交编写的代码,它返回 Mechanize::ResponseCodeError如下。我真的没有在我的代码中看到任何错误,任何人都可以让我知道这是代码错误还是服务器端的错误(比如服务器阻止表单自动提交)?

C:/Ruby193/lib/ruby/gems/1.9.1/gems/mechanize-2.4/lib/mechanize/http/agent.rb:29
1:在 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:in
post_form'
来自 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:in
提交'
来自 auto_post.rb:27:in block in <main>'
from (eval):23:in
form_with'
来自 auto_post.rb:13:in `'

最佳答案

您需要通过像 fiddler 或 charles 这样的调试代理进行代理:

agent.set_proxy 'localhost', 8888

然后类似地代理您的浏览器并比较请求

关于Ruby 表单自动提交 Mechanize::ResponseCodeError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10512505/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com