I'm trying to retrieve the Google Checkout report (Download data to spreadsheet (.csv)). Unfortunatly I can't use the API (it's reserved to only UK and US accounts...!)

I have a script made with Mechanize and Ruby but I have an error : "Net::HTTPBadRequest 1.1 400 Bad Request".

Here is my code :

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
有帮助吗?

解决方案

Thanks to pguardiario and Charles proxy, I found my error... There was a superfluous field!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top