How to use Python Amazon Simple Product API to get

2019-05-16 11:26发布

问题:

I can't seem to get this library working. I got my access key, secret and associate tag. And I am following exact same thing as explained in the README, however I am getting (None, None) instead of price and currency. I don't understand what I am doing wrong. Is it because I signed up on 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:

It was happening because the product I mentioned in the example was no longer available hence it was showing price as 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'