簡體   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