From 5f9536f61d7d19e48fb947da9a4c17a843cbf861 Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Mon, 30 Jul 2012 15:51:04 +0200 Subject: [PATCH] use static IDs of accounts --- modules/ing/backend.py | 2 -- modules/ing/browser.py | 2 +- modules/ing/pages/accounts_list.py | 11 ++++++----- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/modules/ing/backend.py b/modules/ing/backend.py index ffd2789e..8d8c56ca 100644 --- a/modules/ing/backend.py +++ b/modules/ing/backend.py @@ -61,8 +61,6 @@ class INGBackend(BaseBackend, ICapBank): yield account def get_account(self, _id): - if not _id.isdigit(): - raise AccountNotFound() with self.browser: account = self.browser.get_account(_id) if account: diff --git a/modules/ing/browser.py b/modules/ing/browser.py index 6b4f67da..9ca598fb 100644 --- a/modules/ing/browser.py +++ b/modules/ing/browser.py @@ -95,7 +95,7 @@ class Ing(BaseBrowser): elif account.label[0:2] == "LA": # we want "displayTRHistoriqueLA" but this fucking page # is not directly available... - self.location('https://secure.ingdirect.fr/general?command=goToAccount&account=%d&zone=COMPTE' % int(id)) + self.location('https://secure.ingdirect.fr/general?command=goToAccount&account=%d&zone=COMPTE' % int(account._index)) else: raise NotImplementedError() while 1: diff --git a/modules/ing/pages/accounts_list.py b/modules/ing/pages/accounts_list.py index d9e21499..138be836 100644 --- a/modules/ing/pages/accounts_list.py +++ b/modules/ing/pages/accounts_list.py @@ -34,14 +34,15 @@ class AccountsList(BasePage): pass def get_list(self): - ids = [] + ids = set() for td in self.document.xpath('.//td[@nowrap="nowrap"]'): account = Account() link = td.xpath('.//a')[0] - account.id = re.search('\d', link.attrib['href']).group(0) - if not (account.id in ids): - ids.append(account.id) - account.label = unicode(link.text) + account._index = int(re.search('\d', link.attrib['href']).group(0)) + if not account._index in ids: + ids.add(account._index) + account.id = unicode(link.text.strip()) + account.label = account.id urltofind = './/a[@href="' + link.attrib['href'] + '"]' linkbis = self.document.xpath(urltofind).pop() if linkbis.text == link.text: