抓取 Fedex 账单时出现 Ruby Mechanize 405 Net::HTTPMethodNotAllowed 错误
我有一个脚本,每周当他们向我邮寄发票时,都会进入 Fedex Billing,挖掘信息并将其发布到 xpenser.com。最近的 Fedex 计费网站重新设计后,当我运行此代码时:
agent = Mechanize.new
page = agent.get 'http://fedex.com/us/fcl/pckgenvlp/online-billing/'
form = page.form_with(:name => 'logonForm')
form.username = FEDEX['username']
form.password = FEDEX['password']
page = agent.submit form
pp page
我收到此错误:
Mechanize::ResponseCodeError: 405 => Net::HTTPMethodNotAllowed
我看到有一个 javascript 身份验证函数,它似乎构建了一个设置隐藏变量的 URL。我尝试传递变量字符串的各种组合,但没有成功。
虽然 Mechanize 不支持 JavaScript,但它会传入变量字符串,如果您输入了正确的字符串,则可以通过这种方式进行身份验证。我希望能在这里做到这一点。
I have a script that goes into Fedex Billing each week when they mail me my invoice, digs out information and posts it to xpenser.com. After the recent Fedex Billing site redesign, when I run this code:
agent = Mechanize.new
page = agent.get 'http://fedex.com/us/fcl/pckgenvlp/online-billing/'
form = page.form_with(:name => 'logonForm')
form.username = FEDEX['username']
form.password = FEDEX['password']
page = agent.submit form
pp page
I receive this error:
Mechanize::ResponseCodeError: 405 => Net::HTTPMethodNotAllowed
I see there is a javascript auth function that seems to build a URL that sets hidden variables. I've tried to pass various combinations of variable strings in without success.
While Mechanize doesn't support javascript, it will pass in variable strings and if you hit the correct one, you can auth that way. I'm hoping to do that here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 mechanize-1.0.0 可以实现以下效果:
试试这个。它可能会帮助你
Using mechanize-1.0.0 the following works:
try this. it may help you