首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Amazon Product API for python -一个我无法解决的奇怪错误

Amazon Product API for python -一个我无法解决的奇怪错误
EN

Stack Overflow用户
提问于 2013-03-22 22:57:17
回答 1查看 300关注 0票数 0

情况是这样的,我试图让这个API为我工作,但我似乎无法弄清楚它的所有怪癖。即使我运行下面的例子(取自https://bitbucket.org/basti/python-amazon-product-api/src/2b6b628300c4/examples/all-galileo-titles.py),我也会得到随机错误。现在我收到一个错误,说__init__()接受4个参数,而我只给它提供了两个参数。我把所有的凭证放在了正确的位置,但是我在模块中找不到__init__()需要额外参数的地方。有人有什么想法吗?

这是我正在运行的。有关该程序的更多详细信息可以在上面的链接中找到。

代码语言:javascript
复制
from amazonproduct.api import API
import lxml

if __name__ == '__main__':

    # Don't forget to create file ~/.amazon-product-api
    # with your credentials (see docs for details)
    api = API(locale = 'uk')

    result = api.item_search('Books', Publisher= 'RosettaBooks',
        ResponseGroup='Large')

    # extract paging information
    total_results = result.results
    total_pages = len(result)  # or result.pages

    for book in result:

        print 'page %d of %d' % (result.current, total_pages)

        #~ from lxml import etree
        #~ print etree.tostring(book, pretty_print=True)

        print book.ASIN,
        print unicode(book.ItemAttributes.Author), ':',
        print unicode(book.ItemAttributes.Title),
        if hasattr(book.ItemAttributes, 'ListPrice'):
            print unicode(book.ItemAttributes.ListPrice.FormattedPrice)
        elif hasattr(book.OfferSummary, 'LowestUsedPrice'):
            print u'(used from %s)' % book.OfferSummary.LowestUsedPrice.FormattedPrice
EN

回答 1

Stack Overflow用户

发布于 2013-03-26 10:33:11

我也有同样的问题,我在python-amazon-product-api的bitbucket网站上发现了几年前的一个问题,这个问题使我能够解决这个问题。请参阅11/1/2011 new requirement AssociateTag -- update required?

我所做的解决方法不是使用.amazon-product-api文件来指定凭据,而是将它们作为API调用的一部分进行传递:

代码语言:javascript
复制
AWS_KEY = '……….'
SECRET_KEY = '……………'
ASSOCIATE_TAG = '…………….'
api = API(access_key_id=AWS_KEY, secret_access_key=SECRET_KEY, locale="us", associate_tag=ASSOCIATE_TAG)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15573456

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档