抓取 Fedex 账单时出现 Ruby Mechanize 405 Net::HTTPMethodNotAllowed 错误

发布于 2024-11-05 04:19:52 字数 651 浏览 5 评论 0原文

我有一个脚本,每周当他们向我邮寄发票时,都会进入 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我的鱼塘能养鲲 2024-11-12 04:19:52

使用 mechanize-1.0.0 可以实现以下效果:

  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']
  form.add_field!('field_name', 'Page$2')
  page = agent.submit form
  pp page

试试这个。它可能会帮助你

Using mechanize-1.0.0 the following works:

  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']
  form.add_field!('field_name', 'Page$2')
  page = agent.submit form
  pp page

try this. it may help you

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文