Issue #35 resolved

Retrieving MoreSearchResultsURL from ItemSearch

Marco A Morales
created an issue

I'm sorry if this comes off as a complete noob question but I've banged my head against the desk the whole afternoon. I read the API docs and I can't manage to get this to work.

What I'm looking for is the URL that sends the users to Amazon so they can buy a product. I found MoreSearchResultsURL is supposed to be returned by ItemSearch. http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/ItemSearch.html

But no matter what I do I can't find this piece of data. I'm guessing my confusion is on how the XML that the API returns is structured, but I can't find an example that includes this URL.

Here is what I'm trying to do but is obviously wrong.

{{{

!python

api = amazonproduct.API(AWS_KEY, SECRET_KEY, 'us', ASSOCIATE_TAG) print api for book in api.item_search('Books', Author='Carl Sagan'): for book in book.Items.Item: print '%s' % (book.MoreSearchResultsURL) }}}

{{{

!python

Traceback (most recent call last): File "api_test.py", line 11, in <module> print '%s' % (book.MoreSearchResultsURL) File "lxml.objectify.pyx", line 226, in lxml.objectify.ObjectifiedElement.getattr (src/lxml/lxml.objectify.c:2894) File "lxml.objectify.pyx", line 485, in lxml.objectify._lookupChildOrRaise (src/lxml/lxml.objectify.c:5428) AttributeError: no such child: {http://webservices.amazon.com/AWSECommerceService/2011-08-01}MoreSearchResultsURL

}}}

Any light that would shine upon my ignorance will be greatly appreciated. Thanks!

Comments (3)

  1. Sebastian Rahlf repo owner

    Unfortunately Amazon's docs sometimes prove to be a bit inconsistent.

    I find it useful to check the returned XML with

    from lxml import etree
    print etree.tostring(results, pretty_print=True)
    

    I hope that helps a bit.

  2. Marco A Morales reporter

    Thanks! This really helped me to understand how the XML is structured. Maybe you could add this somewhere on the FAQ's for anyone else that might be having trouble like me.

  3. Log in to comment