diff --git a/modules/bnporc/browser.py b/modules/bnporc/browser.py index ce9e7e64..6b320d47 100644 --- a/modules/bnporc/browser.py +++ b/modules/bnporc/browser.py @@ -140,6 +140,9 @@ class BNPorc(BaseBrowser): return None def iter_history(self, id): + if id is None: + return iter([]) + if not self.is_on_page(AccountsList): self.location('/NSFR?Action=DSP_VGLOBALE') @@ -178,6 +181,9 @@ class BNPorc(BaseBrowser): return self.page.iter_operations() def iter_coming_operations(self, id): + if id is None: + return iter([]) + if not self.is_on_page(AccountsList): self.location('/NSFR?Action=DSP_VGLOBALE') execution = self.page.get_execution_id() diff --git a/modules/bnporc/pages/accounts_list.py b/modules/bnporc/pages/accounts_list.py index 0b8b2d1b..3244e2c9 100644 --- a/modules/bnporc/pages/accounts_list.py +++ b/modules/bnporc/pages/accounts_list.py @@ -18,6 +18,7 @@ # along with weboob. If not, see . +import re from decimal import Decimal from weboob.capabilities.bank import Account @@ -50,12 +51,22 @@ class AccountsList(BasePage): def _parse_account(self, tr): account = Account() + account.id = tr.xpath('.//td[@class="libelleCompte"]/input')[0].attrib['id'][len('libelleCompte'):] - account._link_id = account.id if len(str(account.id)) == 23: account.id = str(account.id)[5:21] - account.label = u''+tr.xpath('.//td[@class="libelleCompte"]/a')[0].text.strip() + a = tr.xpath('.//td[@class="libelleCompte"]/a')[0] + m = re.match(r'javascript:goToStatements\(\'(\d+)\'', a.get('onclick', '')) + if m: + account._link_id = m.group(1) + else: + # Can't get history for this account. + account._link_id = None + # To prevent multiple-IDs for CIF (for example), add an arbitrary char in ID. + account.id += 'C' + + account.label = u''+a.text.strip() tds = tr.findall('td') account.balance = self._parse_amount(tds[3].find('a'))