如何使用Python亚马逊简单产品API来获取商品的价格亚马逊、如何使用、简单、商品

2023-09-12 00:05:52 作者:淺唱、呐幸福

我似乎无法得到这的图书馆工作。我得到了我的访问密钥,秘密和准标记。而我下面同样的事情如 README解释,但是我收到(无,无)而不是价格和货币。我不明白我在做什么错。是不是因为我签署了关于amazon.in?

 >>>从amazon.api进口AmazonAPI
>>>亚马逊= AmazonAPI(AMAZON_ACCESS_KEY,AMAZON_SECRET_KEY,AMAZON_ASSOC_TAG)
>>>产品= amazon.lookup(ITEMID ='B0051QVF7A')
>>> product.title
点燃,无线网络连接,6电子墨水屏 - 国际航运
>>> product.price_and_currency
(无,无)
 

解决方案

据发生,因为我在这个例子中提到的产品已不再可用,因此它是显示的价格为

 >>>从amazon.api进口AmazonAPI
 >>>亚马逊= AmazonAPI(AMAZON_ACCESS_KEY,AMAZON_SECRET_KEY,AMAZON_ASSOC_TAG)
 >>>产品= amazon.lookup(ITEMID ='B00EOE0WKQ')
 >>> product.title
 亚马逊消防电话,32GB(AT& T公司)
 >>> product.price_and_currency
 (199.0,美元)
 >>> product.ean
 0848719035209
 >>> product.large_image_url
 http://ecx.images-amazon.com/images/I/51BrZzpkWrL.jpg
 

用Python获取Amazon亚马逊的商品信息

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)

解决方案

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'