0
我試圖檢索Google Checkout報告(將數據下載到電子表格(.csv))。不幸的是,我不能使用API(它只保留給英國和美國帳戶...!)檢索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 protected]'
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
最好的辦法是通過像charles或fiddler這樣的調試器進行代理,與真實的瀏覽器請求進行比較,並對請求進行微調,直到您找到正確的代碼。 – pguardiario
謝謝,它真的幫助!我發現我的錯誤! –