Amazon Product API for python - 一个我无法弄清楚的奇怪错误

问题描述 投票:0回答:1

情况是这样的,我试图让这个 API 为我工作,但我似乎无法弄清楚它的所有怪癖。即使我运行下面的示例(取自 https://bitbucket.org/basti/python-amazon-product-api/src/2b6b628300c4/examples/all-galileo-titles.py),我也会遇到随机错误。现在我得到一个错误,说

__init__()
有 4 个参数,我只给它两个。不过,我将所有凭据都放在了正确的位置,而且我在模块中的任何地方都找不到
__init__()
需要额外参数的地方。有人有什么想法吗?

这是我正在运行的。有关该计划的更多详细信息,请参见上面的链接。

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
python api product amazon-product-api
1个回答
1
投票

我遇到了同样的问题,我在 python-amazon-product-api 的 bitbucket 网站上发现了一个几年前的问题,它使我能够解决这个问题。请参阅 11/1/2011 新要求 AssociateTag——需要更新吗?

我所做的工作是不使用 .amazon-product-api 文件来指定凭证,而是将它们作为 API 调用的一部分传递:

AWS_KEY = '……….'
SECRET_KEY = '……………'
ASSOCIATE_TAG = '…………….'
api = API(access_key_id=AWS_KEY, secret_access_key=SECRET_KEY, locale="us", associate_tag=ASSOCIATE_TAG)
© www.soinside.com 2019 - 2024. All rights reserved.