From a447af21ec941b782cb186d16969677a7048b835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Mart=C3=ADn?= Date: Tue, 22 Sep 2015 20:30:47 +0200 Subject: [PATCH] Handle amazon 502 --- amiibofindr/apps/shop/crawlers/_amazon.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/amiibofindr/apps/shop/crawlers/_amazon.py b/amiibofindr/apps/shop/crawlers/_amazon.py index 29ca525..59ed2c4 100644 --- a/amiibofindr/apps/shop/crawlers/_amazon.py +++ b/amiibofindr/apps/shop/crawlers/_amazon.py @@ -3,6 +3,7 @@ # py from __future__ import unicode_literals from time import sleep +import urllib2 # third party from amazon.api import AmazonAPI @@ -47,7 +48,10 @@ class AmazonBaseCrawler(object): def fetch_batch(self, product_ids): result = [] for chunk_product_ids in chunks(product_ids, self.max_batch_lookup): - products = self.amazon.lookup(ItemId=','.join(chunk_product_ids)) + try: + products = self.amazon.lookup(ItemId=','.join(chunk_product_ids)) + except urllib2.HTTPError: + return result try: for product in products: result.append(self.parse_product(product))