From c6e5f419831098cdc330bf64799595c7dd479adf Mon Sep 17 00:00:00 2001 From: Florent Date: Fri, 22 Feb 2013 09:36:39 +0100 Subject: [PATCH] Get accounts on the new website --- modules/ing/browser.py | 2 +- modules/ing/pages/accounts_list.py | 27 ++++++++------------------- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/modules/ing/browser.py b/modules/ing/browser.py index 795d94eb..842af179 100644 --- a/modules/ing/browser.py +++ b/modules/ing/browser.py @@ -34,7 +34,7 @@ class Ing(BaseBrowser): DEBUG_HTTP = False #DEBUG_HTTP = True ENCODING = None # refer to the HTML encoding - PAGES = {'.*displayTRAccountSummary.*': AccountsList, + PAGES = {'.*pages/index.jsf.*': AccountsList, '.*displayLogin.jsf.*': LoginPage, '.*accountDetail.jsf.*': AccountHistory, '.*displayTRHistorique.*': AccountHistory, diff --git a/modules/ing/pages/accounts_list.py b/modules/ing/pages/accounts_list.py index 42cf2604..6ca67dd0 100644 --- a/modules/ing/pages/accounts_list.py +++ b/modules/ing/pages/accounts_list.py @@ -35,24 +35,13 @@ class AccountsList(BasePage): pass def get_list(self): - ids = set() - for tr in self.document.xpath('//tr[@align="center"]'): - error = tr.xpath('./td/font/b') - if len(error) > 0 and error[0].text == 'ERREUR': - raise BrowserUnavailable() - + # TODO: no idea abount how proxy account are displayed + for a in self.document.xpath('//a[@class="mainclic"]'): account = Account() account.currency = Currency.CUR_EUR - link = tr.xpath('.//a')[0] - 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: - linkbis = self.document.xpath(urltofind)[1] - account.balance = Decimal(FrenchTransaction.clean_amount(linkbis.text)) - account.coming = NotAvailable - yield account + account.id = unicode(a.find('span[@class="account-number"]').text) + account.label = unicode(a.find('span[@class="title"]').text) + balance = a.find('span[@class="solde"]/label').text + account.balance = Decimal(FrenchTransaction.clean_amount(balance)) + account.coming = NotAvailable + yield account