How to get list of product price quotes from Amazon with python-amazon-product-api item_lookup function?

I am trying to write a function to get a list of offers (their prices) for an element based on 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 reading http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/index.html?ItemLookup.html and trying to do 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
+3
source share
2 answers

There seems to be no sentence element in your answer. Try

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

to see what reverse XML looks like.

+6
source

, . , , :

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.Items.Item.Offers.Offer:
        print a.OfferListing.Price.FormattedPrice

amazonproduct http://pypi.python.org/pypi/python-amazon-product-api

+6

Source: https://habr.com/ru/post/1736948/


All Articles