Retrieving MoreSearchResultsURL from ItemSearch

Marco A Morales avatarMarco 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.

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.

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)
Traceback (most recent call last):
  File "", 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: {}MoreSearchResultsURL

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

Comments (3)

  1. Sebastian Rahlf

    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

    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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.