gpt4 book ai didi

python - 使用 python-amazon-simple-product-api 提取最低二手商品价格

转载 作者:行者123 更新时间:2023-12-01 05:02:37 26 4
gpt4 key购买 nike

我正在学习使用 python 通过 python-amazon-simple-product-api 提取二手书价格

这是我当前正在使用的代码:

amazon = AmazonAPI(aws_access_key, 
aws_secret_key,
aws_associate_key)

# products = amazon.search(Keywords=book_demanded_df['isbn01'].values[1], SearchIndex='Books')
products = amazon.search(Keywords='B00CU0NSCU', SearchIndex='All')

# print book_demanded_df['isbn01'].values[1]
for i, product in enumerate(products):
print product.title
print product.asin
print product.get_attribute('Manufacturer')
print product.get_attributes(['ItemDimensions.Width', 'ItemDimensions.Height'])
print product.offer_url

我认为关键应该在get_attributes,我尝试编写类似ItemAttributes.Amount的东西,但事情似乎不起作用。

是否可以使用此 API 来实现此目的?

最佳答案

我是这个小图书馆的作者。亚马逊 API 响应非常困惑,并且根据您查询的产品而有所不同。在上面的示例中,ASIN 属于 Kindle Fire 7"平板电脑系列产品。它包括 8GB 和 16GB 内存版本,每个版本都有不同的 ASIN。例如,B007T36S34 中 8GB 版本的 ASIN。

对于已用价格,API 目前不支持此功能,但您可以使用此作为解决方法:

>>> products[0]._safe_get_element_text(('OfferSummary.LowestUsedPrice.FormattedPrice'))
'$84.99'
>>> products[0]._safe_get_element_text(('OfferSummary.LowestUsedPrice.CurrencyCode'))
'USD'

查看 Amazon Product Advertising API documentation 很有用当搜索这样的数据时。

关于python - 使用 python-amazon-simple-product-api 提取最低二手商品价格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25745363/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com