当前位置: 首页>>代码示例>>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;未经允许,请勿转载。