簡體   English   中英

從Python Amazon Product Advertising API獲取產品的銷售排名-ItemSearch

[英]Get Sales Rank of Product From Python Amazon Product Advertising API - ItemSearch

我已經使用Python從Amazon Product Advertising API獲得了基於搜索索引,瀏覽節點和關鍵字的產品列表。 現在,我必須獲取已獲得的20種產品的列表的銷售排名,但是我無法打印該值。 我可以按產品的銷售排名對列表進行排序,但這並不能提供與每個產品相對應的銷售排名的值。

到目前為止,這是我的代碼:

from amazonproduct import api
import lxml

api = API(locale='us')

def search(index, keyword):
    items = api.item_search(index, BrowseNode = '', Keywords = keyword)
    return items

result = search("Books", "Harry Potter")

count = 0
for item in result:
    print "%s" % (item.ItemAttributes.Title)
    count += 1
    if count == 20:
        break

我最近才研究過Amazon API,但我對它並不熟悉,所以我一直在閱讀文檔並依靠它來找出問題。

在打印Sales_Rank的任何幫助將不勝感激。 非常感謝!

嘗試這個:

print "%s" % (item.SalesRank)

您可以使用pprint類查看item數組的內容。 請參閱此相關文章,了解如何在Python中顯示數組的內容: 如何“很好”地在Python中打印列表

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM