如何使用Python Amazon Simple Product API来获取产品的价格

时间:2014-07-04 12:09:03

标签: python amazon-web-services amazon-product-api

我似乎无法使this库工作。我得到了我的访问密钥,秘密和关联标签。我遵循README中解释的完全相同的事情,但我得到(None, None)而不是价格和货币。我不明白我做错了什么。是因为我注册了amazon.in吗?

>>> from amazon.api import AmazonAPI
>>> amazon = AmazonAPI(AMAZON_ACCESS_KEY, AMAZON_SECRET_KEY, AMAZON_ASSOC_TAG)
>>> product = amazon.lookup(ItemId='B0051QVF7A')
>>> product.title
'Kindle, Wi-Fi, 6" E Ink Display - for international shipment'
>>> product.price_and_currency
(None, None)

1 个答案:

答案 0 :(得分:2)

之所以发生这种情况是因为我在示例中提到的产品已不再可用,因此显示价格为None

 >>> from amazon.api import AmazonAPI
 >>> amazon = AmazonAPI(AMAZON_ACCESS_KEY, AMAZON_SECRET_KEY, AMAZON_ASSOC_TAG)
 >>> product = amazon.lookup(ItemId='B00EOE0WKQ')
 >>> product.title
 'Amazon Fire Phone, 32GB (AT&T)'
 >>> product.price_and_currency
 (199.0, 'USD')
 >>> product.ean
 '0848719035209'
 >>> product.large_image_url
 'http://ecx.images-amazon.com/images/I/51BrZzpkWrL.jpg'