當前位置: 首頁>>代碼示例>>Python>>正文


Python API.similarity_lookup方法代碼示例

本文整理匯總了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
開發者ID:harageth,項目名稱:SWS2012-BookSite,代碼行數:27,代碼來源:amazon.py

示例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)
        
開發者ID:rcbm,項目名稱:thriftfish,代碼行數:27,代碼來源:similar.py

示例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:
開發者ID:sumginazu,項目名稱:dormsaver,代碼行數:32,代碼來源:test_amazon.py


注:本文中的amazonproduct.API.similarity_lookup方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。