1. michilu
  2. python-amazon-product-api


Sebastian Rahlf  committed f571265

Updated documentation.

  • Participants
  • Parent commits a3a393a
  • Branches default
  • Tags 0.2.5

Comments (0)

Files changed (3)

File docs/index.rst

View file
-   pagination

File docs/pagination.rst

-.. _pagination:
-.. index:: pagination
-   single: results; pagination
-.. attention:: The ``ResultPaginator`` only works with ``lxml``!
-The Amazon Product Advertising API paginates some its results. In order to get
-all reviews of a product, for instance, subsequent calls have to be made to the
-API.  Let's have a look at an example:
-We want to fetch all reviews for "Learning Python" (ASIN 0596513984).
-You can, of course, do everthing by hand. For this an initial ::
-    api.item_lookup('0596513984', SearchIndex='Books', ResponseGroup='Reviews')
-is required to find out over just how many result pages the reviews stretch
-(stored in the ``<TotalReviewPages>``) and then call to retrieve each and every
-one of them individually (with an additional ``ReviewPage`` parameter).
-However, rather than writing a looping mechanism yourself, this module provides
-a handy generator method that can be iterated over. All you have to do is to
-define the location of the necessary pagination information using XPath
-    paginator = ResultPaginator('ReviewPage',
-        '//aws:Items/aws:Request/aws:ItemLookupRequest/aws:ReviewPage',
-        '//aws:Items/aws:Item/aws:CustomerReviews/aws:TotalReviewPages',
-        '//aws:Items/aws:Item/aws:CustomerReviews/aws:TotalReviews')
-All that's left is to pass the use method as before and iterate over the 
-    for node in paginator(api.item_lookup, '0596513984', 
-            SearchIndex='Books', ResponseGroup='Reviews'):
-        # ...
-And that's it!

File docs/use-your-own.rst

View file
             return root
     # Now let's use this instead of the default one
-    api = API(AWS_KEY, SECRET_KEY, processor=minidom_response_parser)
+    api = API(AWS_KEY, SECRET_KEY, 'uk', processor=minidom_response_parser)
     root = api.item_lookup('0718155157')
     print root.toprettyxml()
     # ...