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


Python API.item_lookup方法代碼示例

本文整理匯總了Python中amazonproduct.api.API.item_lookup方法的典型用法代碼示例。如果您正苦於以下問題:Python API.item_lookup方法的具體用法?Python API.item_lookup怎麽用?Python API.item_lookup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在amazonproduct.api.API的用法示例。


在下文中一共展示了API.item_lookup方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: amazon

# 需要導入模塊: from amazonproduct.api import API [as 別名]
# 或者: from amazonproduct.api.API import item_lookup [as 別名]
def amazon(query):

    api = API(AWS_KEY, SECRET_KEY, 'us', ASSOC_TAG)

    similar_root = api.similarity_lookup('B0058U6DQC', ResponseGroup='Large')

    product_root = api.item_lookup('B0058U6DQC', ResponseGroup='Large')
    product_root =  api.item_search(title='unicorn', ResponseGroup='Large')
    more_products = api.item_search('Books', Publisher='Galileo Press')
    #~ from lxml import etree
    #~ print etree.tostring(root, pretty_print=True)

    nspace = similar_root.nsmap.get(None, '')
    similar_products = similar_root.xpath('//aws:Items/aws:Item', 
                         namespaces={'aws' : nspace})

    # more_products = product_root.xpath('//aws:Items/aws:Item', 
    #                      namespaces={'aws' : nspace})

    return render_template("amazon.html", similar_products=similar_products, more_products = more_products, query=query)
開發者ID:tatertot,項目名稱:lendinglibrary,代碼行數:22,代碼來源:borrow.py

示例2: parse

# 需要導入模塊: from amazonproduct.api import API [as 別名]
# 或者: from amazonproduct.api.API import item_lookup [as 別名]
    """
    Custom response parser using BeautifulSoup to parse the returned XML.
    """

    def parse(self, fp):

        soup = BeautifulSoup.BeautifulSoup(fp.read())

        # parse errors
        for error in soup.findAll('error'):
            code = error.find('code').text
            msg = error.find('message').text
            raise AWSError(code, msg)

        return soup

if __name__ == '__main__':

    # Don't forget to create file ~/.amazon-product-api
    # with your credentials (see docs for details)
    api = API(locale='us', processor=SoupProcessor())
    result = api.item_lookup('0718155157')
    
    print result
    
    # ...
    # now do something with it! 
    
    
開發者ID:Yappawu,項目名稱:python-amazon-product-api,代碼行數:29,代碼來源:using-beautifulsoup.py

示例3: minidom_response_parser

# 需要導入模塊: from amazonproduct.api import API [as 別名]
# 或者: from amazonproduct.api.API import item_lookup [as 別名]
from xml.dom.minidom import parse


def minidom_response_parser(fp):
    """
    Custom response parser using xml.dom.minidom.parse 
    instead of lxml.objectify.
    """
    root = parse(fp)
    
    # parse errors
    for error in root.getElementsByTagName('Error'):
        code = error.getElementsByTagName('Code')[0].firstChild.nodeValue
        msg = error.getElementsByTagName('Message')[0].firstChild.nodeValue
        raise AWSError(code, msg)
    
    return root

if __name__ == '__main__':
    
    api = API(AWS_KEY, SECRET_KEY, 'us',
              processor=minidom_response_parser)
    root = api.item_lookup('0718155157')
    
    print root.toprettyxml()
    
    # ...
    # now do something with it! 
    
    
開發者ID:Root-nix,項目名稱:python-amazon-product-api,代碼行數:30,代碼來源:using-xml-minidom.py

示例4: len

# 需要導入模塊: from amazonproduct.api import API [as 別名]
# 或者: from amazonproduct.api.API import item_lookup [as 別名]
Get all editorial reviews for books with the specified ISBNs.
"""

import sys

from amazonproduct.api import API

if __name__ == '__main__':
    
    if len(sys.argv[1:]) == 0:
        print __doc__
        print 'Usage: %s ISBN' % sys.argv[0]
        sys.exit(1)
    
    for isbn in sys.argv[1:]:

        isbn = isbn.replace('-', '')

        # Don't forget to create file ~/.amazon-product-api
        # with your credentials (see docs for details)
        api = API(locale='us')
        for root in api.item_lookup(isbn, IdType='ISBN', 
                             SearchIndex='Books', ResponseGroup='EditorialReview'):
            nspace = root.nsmap.get(None, '')
            reviews = root.xpath('//aws:EditorialReview', 
                                namespaces={'aws' : nspace})
            for review in reviews:
                print unicode(review.Source)
                print '-' * 40
                print unicode(review.Content)
開發者ID:Yappawu,項目名稱:python-amazon-product-api,代碼行數:32,代碼來源:reviews.py

示例5: SoupProcessor

# 需要導入模塊: from amazonproduct.api import API [as 別名]
# 或者: from amazonproduct.api.API import item_lookup [as 別名]
# -*- coding: utf-8 -*-

from amazonproduct.api import API
from amazonproduct.errors import AWSError
from amazonproduct.processors import BaseProcessor

import BeautifulSoup


class SoupProcessor(BaseProcessor):
    def parse(self, fp):
        soup = BeautifulSoup.BeautifulSoup(fp.read())

        for error in soup.findAll('error'):
            code = error.find('code').text
            msg = error.find('message').text
            raise AWSError(code, msg)

        return soup

if __name__ == '__main__':

    api = API(locale='jp', processor=SoupProcessor())
    result = api.item_lookup('B00LCL7A3G')

    print result
開發者ID:raindrop-aqua,項目名稱:learn-python,代碼行數:28,代碼來源:item_lookup.py

示例6: credentials

# 需要導入模塊: from amazonproduct.api import API [as 別名]
# 或者: from amazonproduct.api.API import item_lookup [as 別名]
    # Don't forget to create file ~/.amazon-product-api
    # with your credentials (see docs for details)
    api = API(locale=options.locale)
    
    params = {
        'ResponseGroup' : 'Images',
        'SearchIndex' : 'All',
        'IdType' : options.id_type, 
    }
    
    # When IdType equals ASIN, SearchIndex cannot be present.
    if options.id_type == ASIN:
        del params['SearchIndex']

    for id in ids:
        
        id = id.replace('-', '')
        
        if options.verbose: print 'Fetching info for %s...' % id
        root = api.item_lookup(id, **params)
        
        #~ from lxml import etree
        #~ print etree.tostring(root, pretty_print=True)
        
        url = root.Items.Item.LargeImage.URL.pyval
        name, ext = os.path.splitext(url)
        path = '%s%s' % (id, ext)
        if options.verbose: print 'Downloading %s to %s ...' % (url, path)
        fetch_image(url, path)
        
開發者ID:Yappawu,項目名稱:python-amazon-product-api,代碼行數:31,代碼來源:get-cover.py


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