简体   繁体   中英

Accessing Amazon Seller Central with Python

I am trying to create an application that:

  1. Logs into the Amazon Seller Central

  2. Opens up several pages contained within, retrieves the rendered page source including values that were populated by javascript

  3. Parses that rendered page source and outputs a report for the user. (This part is complete)

I have been able to manually complete this task by using the firefox addon firebug to view the rendered page source, copying that to a file and I have finished writing the parser. However, I want to automate this process and make it as user friendly as possible to share with individuals who may not be very technically savvy.

My difficulty has been in completing steps 1 and 2 using Python. I have been doing a lot of searching and reading about using the libraries urllib, urllib2, and cookielib, but I haven't been able to figure out how to get it working properly.

For example I found this snippet here on stackoverflow:

import urllib, urllib2, cookielib

username = "xxx"
password = "xxx"

cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
login_data = urllib.urlencode({'username':username,'j_password':password})
opener.open('https://sellercentral.amazon.com/gp/homepage.html', login_data)
resp = opener.open('https://sellercentral.amazon.com/myi/search      /ItemSummary.amzn?')
print resp.read()

Now, I know that my opener.open is wrong, but I don't know where I can find the Amazon seller central login script that I need to point this at.

Also, I am not sure if I am going about this in the right way. Any direction is greatly appreciated.

Have a look at this

http://seleniumhq.org/

Or this

http://wwwsearch.sourceforge.net/mechanize/j

Might be a bit easier in a browser enviroment to do what you want.

br.select_form(name="order")
# Browser passes through unknown attributes (including methods)
# to the selected HTMLForm.
br["cheeses"] = ["mozzarella", "caerphilly"]  # (the method here is __setitem__)
# Submit current form.  Browser calls .close() on the current response on
# navigation, so this closes response1
response2 = br.submit()

See Amazon Marketplace Web Services as an alternative. They don't appear to have a Python library, but there are clients for other languages .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM