【问题标题】:Accessing Amazon Seller Central with Python使用 Python 访问亚马逊卖家中心
【发布时间】:2012-09-23 19:55:29
【问题描述】:

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

  1. 登录Amazon Seller Central

  2. 打开其中包含的多个页面,检索呈现的页面源 包括由 javascript 填充的值

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

我已经能够通过使用 firefox 插件 firebug 查看呈现的页面源,将其复制到文件来手动完成此任务,并且我已经完成了解析器的编写。不过,我想自动化这个过程,让它尽可能方便用户使用,以便与可能不太精通技术的人分享。

我的困难在于使用 Python 完成第 1 步和第 2 步。我一直在做很多关于使用库 urllib、urllib2 和 cookielib 的搜索和阅读,但我无法弄清楚如何让它正常工作。

例如,我在 stackoverflow 上找到了这个 sn-p:

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 是错误的,但我不知道在哪里可以找到我需要指出的亚马逊卖家中心登录脚本。

另外,我不确定我是否以正确的方式处理这件事。非常感谢任何方向。

【问题讨论】:

    标签: python web amazon urllib2 urllib


    【解决方案1】:

    看看这个

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

    【讨论】:

    • 感谢您的资源,我将开始研究这些资源,看看是否能找到一种方法来做我需要的事情。
    【解决方案2】:

    另请参阅Amazon Marketplace Web Services。他们似乎没有 Python 库,但有 clients for other languages

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-10-23
      • 1970-01-01
      • 2016-03-08
      • 2023-03-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多