1. Sebastian Rahlf
  2. python-amazon-product-api
  3. Issues
Issue #2 resolved

ResultPaginator raises IndexError for reviews

Sebastian Rahlf
repo owner created an issue

I wanted to get a list of reviews for a particular book. When using the ResultPaginator from the examples

{{{ paginator = amazonproduct.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')

for root in paginator(api.item_lookup, id=isbn, IdType='ISBN', SearchIndex='Books', ResponseGroup='Reviews'): ... }}}

I got the following error.

{{{ Traceback (most recent call last): File ".../reviews/utils.py", line 257, in <module> for review in get_amazon_reviews(title['isbn']): File ".../reviews/utils.py", line 122, in get_amazon_reviews SearchIndex='Books', ResponseGroup='Reviews'): File ".../site-packages/amazonproduct.py", line 410, in call total_results = self.get_total_results(root) File ".../site-packages/amazonproduct.py", line 436, in get_total_results namespaces={'aws' : self.nspace})[0].pyval IndexError: list index out of range }}}

Turns out that the Reviews node wasn't in the XML response.

Comments (2)

  1. Log in to comment