本文整理汇总了Python中amazonproduct.API.similarity_lookup方法的典型用法代码示例。如果您正苦于以下问题:Python API.similarity_lookup方法的具体用法?Python API.similarity_lookup怎么用?Python API.similarity_lookup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类amazonproduct.API
的用法示例。
在下文中一共展示了API.similarity_lookup方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_similar_books
# 需要导入模块: from amazonproduct import API [as 别名]
# 或者: from amazonproduct.API import similarity_lookup [as 别名]
def get_similar_books(ASIN):
api = API(AWS_KEY, SECRET_KEY, 'us', ASSOCIATE_TAG)
for root in api.similarity_lookup(str(ASIN)):
try:
current_page = root.Items.Request.ItemSearchRequest.ItemPage.pyval
except AttributeError:
current_page = 1
#print 'page %d of %d' % (current_page, total_pages)
nspace = root.nsmap.get(None, '')
books = root.xpath('//aws:Items/aws:Item', namespaces={'aws' : nspace})
similar_items = []
i = 0
for book in books:
if (i==3):
return similar_items
similar_items.append(book)
i = i + 1
示例2: API
# 需要导入模块: from amazonproduct import API [as 别名]
# 或者: from amazonproduct.API import similarity_lookup [as 别名]
"""
Find similar items to "Small Favor: A Novel of the Dresden Files"
(ASIN 0451462009).
"""
from config import AWS_KEY, SECRET_KEY
from amazonproduct import API
from amazonproduct import ResultPaginator
if __name__ == '__main__':
api = API(AWS_KEY, SECRET_KEY, 'us')
root = api.similarity_lookup('0451462009')
#~ from lxml import etree
#~ print etree.tostring(root, pretty_print=True)
nspace = root.nsmap.get(None, '')
books = root.xpath('//aws:Items/aws:Item',
namespaces={'aws' : nspace})
for book in books:
print 'ASIN %-10s' % book.ASIN,
print unicode(book.ItemAttributes.Author), ':',
print unicode(book.ItemAttributes.Title)
示例3: open
# 需要导入模块: from amazonproduct import API [as 别名]
# 或者: from amazonproduct.API import similarity_lookup [as 别名]
print d[0][0]
"""
f = open("recommendations.txt", "a")
count = 0
g = open("prices.txt", "a")
for item in items:
a = item.ASIN
result = api.item_lookup(str(a))
#for i in result.Items.Item:
#print '%s (%s) in group' % (i.ItemAttributes.Title, i.ASIN)
try:
result = api.similarity_lookup(str(a))
for b in result.Items.Item:
# print '%s (%s)' % (b.ItemAttributes.Title, b.ASIN)
if count >= 20:
break
image = api.item_lookup(str(b.ASIN), ResponseGroup = "Images")
price = api.item_lookup(str(b.ASIN), ResponseGroup = "Offers")
for i in image.Items.Item:
# print '%s' % i.LargeImage.URL
if(i.LargeImage.URL != None):
f.write("%s $ %s\n" % (b.ItemAttributes.Title, b.DetailPageURL))
count += 1
for i in price.Items.Item:
print '%s' % i.OfferSummary.LowestNewPrice.FormattedPrice
g.write("%s @ %s\n" % (b.ItemAttributes.Title, i.OfferSummary.LowestNewPrice.FormattedPrice))
except Exception,e: