我想得到amazon的類別,我計劃廢棄不用API。
我已經取消了http://www.amazon.com,我已經在Shop By Department下拉列表中抓取了所有的類別和子類別,我創建了一個web服務來完成這項工作,代碼就在這里@route('/hello')
def hello():
text=list();
link=list();
req = urllib2.Request("http://www.amazon.com",
headers={"Content-Type": "application/json"})
html=urllib2.urlopen(req).read()
soup = BeautifulSoup(html)
last_page = soup.find('div', id="nav_subcats")
for elm in last_page.findAll('a'):
texts = elm.text
links = elm.get('href')
links = links.partition("&node=")[2]
text.append(texts)
link.append(links)
alltext=list();
for i,j in zip(text,link):
alltext.append({"name":i,"id":j})
response.content_type = 'application/json'
print(alltext)
return dumps(alltext)
run(host='localhost', port=8080, debug=True)
我將category name和category id作為JSON對象傳遞給我的一個成員,以將其傳遞給API以獲取每個類別的產品列表
它是用文字寫的爪哇。這里是密碼嗎
^{pr2}$
但是,當我將類別id作為BrowseNodeId傳遞,將類別名稱作為關鍵字和搜索索引傳遞時,會遇到此錯誤。在For example
Search Index and Keyword -Amazon Instant Video
BrowseNodeId-2858778011
The value you specified for SearchIndex is invalid. Valid values include [ 'All','Apparel',...................................reless','WirelessAccessories' ].
我想知道從哪個亞馬遜網址我將得到所有的類別和它的瀏覽節點
謝謝你