[英]Checking trade in value for video games
I'm trying to get the trade in value on a video game using the python amazon api. 我正在尝试使用python amazon api获取视频游戏的价值交易。 http://python-amazon-product-api.readthedocs.org/en/latest/
http://python-amazon-product-api.readthedocs.org/en/latest/
I have tried running this code: 我尝试运行此代码:
from amazonproduct import API
api = API(locale='us')
items = api.item_search('VideoGames', Keywords='Metal Gear Solid',IsEligibleForTradeIn ='1')
for item in items:
if item.ItemAttributes.TradeInValue.Amount:
print '%s: %d' % (item.ItemAttributes.Title, item.ItemAttributes.TradeInValue.Amount)
But I get an AttributeError claiming there is no such child "TradeInValue" 但是我得到一个AttributeError,声称没有这样的子级“ TradeInValue”
This code works until I ask for trade in value, is tradeInValue a valid attribute for video games? 该代码在我要求进行价值交易之前一直有效,tradeInValue是视频游戏的有效属性吗?
EDIT : Print out for print item.__dict__
编辑 :打印出
print item.__dict__
{'ItemAttributes': <Element {http://webservices.amazon.com/AWSECommerceService/2011-08-01}ItemAttributes at 0x7f7a1b117128>, 'ASIN': 'B00JKM06HG', 'ItemLinks': <Element {http://webservices.amazon.com/AWSECommerceService/2011-08-01}ItemLinks at 0x7f7a1b1177e8>, 'DetailPageURL': 'http://www.amazon.com/Metal-Gear-Solid-Phantom-Pain-PlayStation/dp/', 'ParentASIN': 'B00KVVSONI'}
After researching some of the info provided by you and the docs for item_search and item_lookup 在研究了您和item_search和item_lookup的文档提供的一些信息之后
It looks like item_lookup
(and I presume item_search
) can return some or all of the attributes, depending on the response group specified in the request. 看起来
item_lookup
(我假设item_search
)可以返回一些或所有属性,具体取决于请求中指定的响应组。 By default, item_lookup
, returns an item's ASIN, Manufacturer, ProductGroup, and Title of the item. 默认情况下,
item_lookup
返回项目的ASIN,制造商,产品组和项目的标题。
While going through the available ResponseGroups on AWS, I discovered ItemAttributes
, which also returns TradeInValue
as described here . 虽然经历可用ResponseGroups在AWS上,我发现
ItemAttributes
,这也将返回TradeInValue
描述这里 。 I don't have an Amazon Developer account set up, however, you could try changing your search parameters to the below (and see if the additional attributes show up) 我没有设置Amazon Developer帐户,但是,您可以尝试将搜索参数更改为以下内容(并查看是否显示了其他属性)
items = api.item_search(
'VideoGames',
Keywords='Metal Gear Solid',
IsEligibleForTradeIn='1',
ResponseGroup='ItemAttributes'
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.