从Python亚马逊产品广告API获取产品的销售排名 - ItemSearch

时间:2017-04-14 00:25:01

标签: python amazon rank amazon-product-api sales

我已经使用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

我刚刚查看了亚马逊API并且我对它非常不熟悉,所以我刚刚阅读了文档并依靠它来解决问题。

任何有关打印Sales_Rank的帮助都将非常感谢。非常感谢!

1 个答案:

答案 0 :(得分:0)

试试这个:

print "%s" % (item.SalesRank)

您可以使用pprint类查看item数组的内容。请参阅此相关文章,了解如何在Python中显示数组的内容:How to print a list in Python "nicely"