Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_kindle_sales(cs_user,cs_pass)
- session = Mechanize.new
- session.user_agent_alias = 'Mac Safari'
- session.get 'https://www.amazon.com/ap/signin?openid.assoc_handle=amzn_dtp&openid.identity=' #...etc.
- form = session.get('https://www.amazon.com/ap/signin?openid.assoc_handle=amzn_dtp&openid.=' + # ...etc.
- '...').form_with(:name => 'signIn')
- params = {'email' => cs_user, 'password' => cs_pass}
- %w(appActionToken appAction openid.pape.max_auth_age openid.ns).each do |field| # there's more, actually
- params[field] = form[field]
- end
- session.post('https://www.amazon.com/ap/signin', params)
- response = session.get('https://kdp.amazon.com/self-publishing/reports/transactionReport?_=1326589411161&previousMonthReports=false&marketplaceID=ATVPDKIKX0DER')
- # note non-RESTful concept of "previousMonthReports" in URI
- hash = JSON.parse(response.body)
- kindle_units = hash['aaData'][0][5]
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement