From ce65d350819bab79ef438fb7fe5086de469fe67c Mon Sep 17 00:00:00 2001 From: Oleg Plakhotniuk Date: Fri, 13 Mar 2015 18:14:59 -0500 Subject: [PATCH] [amazon] Support for a new payment layout and priceless items. Fixes #1764 --- modules/amazon/pages.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/modules/amazon/pages.py b/modules/amazon/pages.py index 253be730..520648a1 100644 --- a/modules/amazon/pages.py +++ b/modules/amazon/pages.py @@ -131,11 +131,15 @@ class OrderNewPage(OrderPage): break def paymethods(self): - for root in self.doc.xpath('//h5[contains(text(),"Payment Method")]'): - alt = root.xpath('../div/img/@alt')[0] - span = root.xpath('../div/span/text()')[0] - digits = re.match(r'[^0-9]*([0-9]+)[^0-9]*', span).group(1) - yield u'%s %s' % (alt, digits) + for root in self.doc.xpath(u'//h5[contains(text(),"Payment Method")]'): + div = u''.join(root.xpath('../div/text()')).strip() + if div: + yield div + else: + alt = root.xpath('../div/img/@alt')[0] + span = root.xpath('../div/span/text()')[0] + digits = re.match(r'[^0-9]*([0-9]+)[^0-9]*', span).group(1) + yield u'%s %s' % (alt, digits) def grand_total(self): return AmTr.decimal_amount(self.doc.xpath( @@ -205,7 +209,7 @@ class OrderNewPage(OrderPage): if url: url = unicode(self.browser.BASEURL) + \ re.match(u'(/gp/product/.*)/ref=.*', url).group(1) - if label and price: + if label: itm = Item() itm.label = label itm.url = url