From dd12d8cc3c048bd6533ab93cb3722164a48d6b6b Mon Sep 17 00:00:00 2001 From: Jay Fault Date: Sun, 26 Mar 2017 10:26:14 -0400 Subject: [PATCH 1/2] Fix amazon Pretty messy --- plugins/amazon.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/amazon.py b/plugins/amazon.py index ed9124097..d0b1e7a2f 100644 --- a/plugins/amazon.py +++ b/plugins/amazon.py @@ -74,7 +74,12 @@ def amazon(text, _parsed=False): r"|Spedizione gratuita)", item.text, re.I): tags.append("$(b)Free Shipping$(b)") - price = item.find('span', {'class': ['s-price', 'a-color-price']}).text + try: + price = item.find('span', {'class': ['s-price', 'a-color-price']}).text + except AttributeError: + for i in item.find_all('sup', class_='sx-price-fractional'): + i.string.replace_with('.' + i.string) + price = item.find('span', {'class': 'sx-price'}).text # use a whole lot of BS4 and regex to get the ratings try: From 3db00a7d9a1b93f5add4268d93c746149e7ae74d Mon Sep 17 00:00:00 2001 From: Jay Fault Date: Sun, 26 Mar 2017 10:32:53 -0400 Subject: [PATCH 2/2] Consistency? We could probably just use `class_` everywhere tbh but I'm lazy --- plugins/amazon.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/amazon.py b/plugins/amazon.py index d0b1e7a2f..8a6a65c95 100644 --- a/plugins/amazon.py +++ b/plugins/amazon.py @@ -77,7 +77,7 @@ def amazon(text, _parsed=False): try: price = item.find('span', {'class': ['s-price', 'a-color-price']}).text except AttributeError: - for i in item.find_all('sup', class_='sx-price-fractional'): + for i in item.find_all('sup', {'class': 'sx-price-fractional'}): i.string.replace_with('.' + i.string) price = item.find('span', {'class': 'sx-price'}).text