From 7502310d7e05700ce879d3448942243519d5d0ae Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Sat, 1 Mar 2014 19:23:06 +0100 Subject: [PATCH] fix crash when the card history is empty --- modules/boursorama/pages/card_history.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/boursorama/pages/card_history.py b/modules/boursorama/pages/card_history.py index 20fc982c..267ce018 100644 --- a/modules/boursorama/pages/card_history.py +++ b/modules/boursorama/pages/card_history.py @@ -40,10 +40,11 @@ class CardHistory(BasePage): def get_operations(self): for form in self.document.xpath('//form[@name="marques"]'): for tr in form.xpath('.//tbody/tr'): - if tr.attrib.get('class', '') == 'total' or 'style' in tr.attrib: + tds = tr.xpath('./td') + + if tr.attrib.get('class', '') == 'total' or 'style' in tr.attrib or len(tds) < 3: continue - tds = tr.xpath('./td') date = self.parser.tocleanstring(tds[0]) label = self.parser.tocleanstring(tds[1]) amount = self.parser.tocleanstring(tds[2])