繁体   English   中英

使用Python访问Amazon Seller Central

[英]Accessing Amazon Seller Central with Python

我正在尝试创建一个应用程序,该应用程序:

  1. 登录到Amazon Seller Central

  2. 打开其中包含的几个页面,检索渲染的页面源,包括由javascript填充的值

  3. 解析呈现的页面源并为用户输出报告。 (这部分完成了)

通过使用firefox插件firebug查看呈现的页面源并将其复制到文件中,我已经能够手动完成此任务,并且我已经完成了解析器的编写。 但是,我想使此过程自动化,并使其尽可能对用户友好,以便与技术上不太熟练的人共享。

我的困难在于使用Python完成步骤1和2。 我一直在大量搜索和阅读有关使用库urllib,urllib2和cookielib的信息,但是我一直无法弄清楚如何使其正常工作。

例如,我在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()

现在,我知道我的opener.open是错误的,但是我不知道在哪里可以找到需要指向的亚马逊卖家中央登录脚本。

另外,我不确定是否要以正确的方式进行操作。 任何方向都将不胜感激。

看看这个

http://seleniumhq.org/

或这个

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

在浏览器环境中执行您想要的操作可能会容易一些。

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()

请参阅Amazon Marketplace Web服务作为替代。 他们似乎没有Python库,但是有其他语言的客户端

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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