情况就是这样,我试图让这个 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