本文介绍了如何获得的价格优惠清单上的项目从亚马逊与Python,亚马逊产品的API item_lookup功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图写一个函数来获取优惠(其价格)的基础上,ASIN的项目清单:

 高清price_offers(ASIN):
    从amazonproduct进口API,ResultPaginator,AWSError
    从配置进口AWS_KEY,SECRET_KEY
    API = API(AWS_KEY,SECRET_KEY,'德')
    str_asin = STR(ASIN)
    节点= api.item_lookup(ID = str_asin,ResponseGroup ='娱乐',条件='所有',MerchantId ='所有')
    对于在节点:
        打印a.Offer.OfferListing.Price.FormattedPrice
 

我读的并试图使这项工作,但所有的时间它只是说:

 故障实例:回溯:<键入'exceptions.AttributeError'计算值:没有这样的孩子:{http://webservices.amazon.com/AWSECommerceService/2009-10-01 }提供
 

解决方案

好像有在你的回应中没有报价的元素。尝试

 节点= api.item_lookup(...)
从LXML进口etree
打印etree.tostring(节点,pretty_print = TRUE)
 

要看到返回的XML的样子。

I am trying to write a function to get a list of offers (their prices) for an item based on the ASIN:

def price_offers(asin):
    from amazonproduct import API, ResultPaginator, AWSError
    from config import AWS_KEY, SECRET_KEY
    api = API(AWS_KEY, SECRET_KEY, 'de')
    str_asin = str(asin)
    node = api.item_lookup(id=str_asin, ResponseGroup='Offers', Condition='All', MerchantId='All')
    for a in node:
        print a.Offer.OfferListing.Price.FormattedPrice

I am readinghttp://docs.amazonwebservices.com/AWSECommerceService/latest/DG/index.html?ItemLookup.html and trying to make this work, but all the time it just says:

Failure instance: Traceback: <type 'exceptions.AttributeError'>: no such child: {http://webservices.amazon.com/AWSECommerceService/2009-10-01}Offer
解决方案

Seems like there is no Offer element in your response. Try

node = api.item_lookup(...)
from lxml import etree
print etree.tostring(node, pretty_print=True)

to see how the returned XML looks like.

这篇关于如何获得的价格优惠清单上的项目从亚马逊与Python,亚马逊产品的API item_lookup功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-13 21:28