From 8dcc28a7053656103b9bdb95d5c4e8256e2e49dd Mon Sep 17 00:00:00 2001 From: Caram Dache Date: Thu, 30 Jul 2015 23:06:28 +0200 Subject: [PATCH] bp: better card number detection --- modules/bp/pages/accounthistory.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/bp/pages/accounthistory.py b/modules/bp/pages/accounthistory.py index 7175315f..b9ebc454 100644 --- a/modules/bp/pages/accounthistory.py +++ b/modules/bp/pages/accounthistory.py @@ -63,11 +63,13 @@ class AccountHistory(Page): operations = [] if deferred: - card_no_re = re.compile('indexCarte=(\d)') - card_no = card_no_re.search(self.url).group(0).replace('indexCarte=', '') - - # look for the debit date, and if it is already debited + # look for the card number, debit date, and if it is already debited txt = u''.join([txt.strip() for txt in self.document.xpath('//div[@class="infosynthese"]')[0].itertext()]) + m = re.search(u'sur votre carte n°\*\*\*\*\*\*(\d+)\*', txt) + card_no = u'inconnu' + if m: + card_no = m.group(1) + m = re.search('(\d+)/(\d+)/(\d+)', txt) if m: debit_date = datetime.date(*map(int, reversed(m.groups())))