0

我正在尝试检索 Google Checkout 报告(将数据下载到电子表格 (.csv))。不幸的是,我不能使用 API(它只保留给英国和美国帐户......!)

我有一个用 Mechanize 和 Ruby 制作的脚本,但我有一个错误:“Net::HTTPBadRequest 1.1 400 Bad Request”。

这是我的代码:

require 'rubygems'
require 'mechanize'
require 'logger'

agent = Mechanize.new { |a| a.log = Logger.new(STDERR) }
agent.user_agent_alias = 'Mac Safari'
page = agent.get 'https://checkout.google.com/sell/orders'

form = page.forms.first
form.Email = 'email@gmail.com'
form.Passwd = 'password'
page = agent.submit(form, form.buttons.first)

form = page.forms.last
p form
form['start-date'] = "2012-11-16"
form['end-date'] = "2012-11-17"
form['column-style'] = "EXPANDED"
#form['_type'] = "order-list-request"
#form['date-time-zone'] = "America/Los_Angeles"
#form['financial-state'] = ""
#form['query-type'] = ""
p form

begin
  page = agent.submit(form, form.buttons.first)
rescue Mechanize::ResponseCodeError => ex
  puts ex.page.body
end
4

1 回答 1

0

感谢 pguardiario 和 Charles 代理,我发现了我的错误……有一个多余的字段!

于 2012-11-20T20:41:23.860 回答