From 8aa3a10d2abb1625483a320ee9fc6cda819f27cb Mon Sep 17 00:00:00 2001 From: sputnick Date: Wed, 22 Aug 2012 14:45:15 +0200 Subject: [PATCH] patch since fortuneo web site changes --- modules/fortuneo/browser.py | 11 ++++++---- modules/fortuneo/pages/accounts_list.py | 29 +++++++++++++++---------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/modules/fortuneo/browser.py b/modules/fortuneo/browser.py index 8cd8b3b8..bf9cc620 100644 --- a/modules/fortuneo/browser.py +++ b/modules/fortuneo/browser.py @@ -34,14 +34,17 @@ class Fortuneo(BaseBrowser): PAGES = { '.*identification.jsp.*': LoginPage, - '.*/prive/mes-comptes/synthese-tous-comptes\.jsp.*': + '.*/prive/mes-comptes/synthese-tous-comptes.jsp': + AccountsList, + '.*/prive/mes-comptes/synthese-mes-comptes\.jsp': + #'.*/prive/mes-comptes/synthese-tous-comptes\.jsp.*': AccountsList, '.*/prive/mes-comptes/livret/consulter-situation/consulter-solde\.jsp\?COMPTE_ACTIF=.*': AccountHistoryPage, '.*/prive/mes-comptes/compte-courant/consulter-situation/consulter-solde\.jsp\?COMPTE_ACTIF=.*': AccountHistoryPage, '.*/prive/default\.jsp.*': - AccountsList + AccountsList } def __init__(self, *args, **kwargs): @@ -72,7 +75,7 @@ class Fortuneo(BaseBrowser): self.location('https://' + self.DOMAIN_LOGIN + '/fr/identification.jsp') self.page.login(self.username, self.password) - self.location('https://' + self.DOMAIN_LOGIN + '/fr/prive/mes-comptes/synthese-tous-comptes.jsp') + self.location('https://' + self.DOMAIN_LOGIN + '/fr/prive/mes-comptes/synthese-mes-comptes.jsp') def get_history(self, account): if not self.is_on_page(AccountHistoryPage): @@ -83,7 +86,7 @@ class Fortuneo(BaseBrowser): """accounts list""" if not self.is_on_page(AccountsList): - self.location('https://' + self.DOMAIN_LOGIN + '/fr/prive/mes-comptes/synthese-tous-comptes.jsp') + self.location('https://' + self.DOMAIN_LOGIN + '/fr/prive/mes-comptes/synthese-mes-comptes.jsp') return self.page.get_list() diff --git a/modules/fortuneo/pages/accounts_list.py b/modules/fortuneo/pages/accounts_list.py index 36f711ad..6714f04c 100644 --- a/modules/fortuneo/pages/accounts_list.py +++ b/modules/fortuneo/pages/accounts_list.py @@ -68,32 +68,37 @@ class AccountsList(BasePage): def get_list(self): l = [] - for cpt in self.document.xpath(".//*[@id='tableauComptesTitEtCotit']/tbody/tr"): + for cpt in self.document.xpath(".//*[@class='synthese_id_compte']"): account = Account() # account.id - account.id = cpt.xpath("./td[1]/a/text()")[0] + account.id = cpt.xpath("./span/text()")[0].replace(u"\xa0", "").replace(',', '.').replace("EUR", "").replace("\n", "").replace("\t", "").replace(u"\xb0", '').replace(" ", "").replace('N', '') + print "DEBUG account.id=[",str(account.id),"]\n" # account balance - account.balance = Decimal(cpt.xpath("./td[3]/text()")[0].replace(',', '.').replace("EUR", "").replace("\n", "").replace("\t", "").replace(u"\xa0", "")) + account.balance = Decimal(cpt.xpath("./span/text()")[1].replace("+", "").replace(u"\xa0", "").replace(',', '.').replace("EUR", "").replace("\n", "").replace("\t", "").replace(" ", "")) + print "DEBUG account.balance=["+str(account.balance)+"]\n" - # account coming - mycomingval = cpt.xpath("./td[4]/text()")[0].replace(',', '.').replace("EUR", "").replace("\n", "").replace("\t", "").replace(u"\xa0", "") + # account coming TODO + #mycomingval = cpt.xpath("../../following-sibling::*[1]/td[2]/a[@class='lien_synthese_encours']/span/text()")[0].replace(',', '.').replace("EUR", "").replace("\n", "").replace("\t", "").replace(u"\xa0", "") + #mycomingval = cpt.xpath("../../following-sibling::*[1]/td[2]")[0] + #mycomingval = cpt.xpath("./../../../a[@class='lien_synthese_encours']/span[@class='synthese_encours']/text()")[0].replace(',', '.').replace("EUR", "").replace("\n", "").replace("\t", "").replace(u"\xa0", "") + #print "DEBUG mycomingval=", mycomingval.Getchildren - if mycomingval == '-': - account.coming = Decimal(0) - else: - account.coming = Decimal(mycomingval) + #if mycomingval == '-': + # account.coming = Decimal(0) + #else: + # account.coming = Decimal(mycomingval) # account._link_id - url_to_parse = cpt.xpath('./td[1]/a/@href')[0] # link + url_to_parse = cpt.xpath('@href')[0].replace("\n", "") # link + print "DEBUG cpt.xpath=["+str(cpt.xpath)+"]\n" compte_id_re = re.compile(r'/prive/mes-comptes/([^/]+/).*COMPTE_ACTIF=([^\&]+)\&?') account._link_id = '/fr/prive/mes-comptes/%sconsulter-situation/consulter-solde.jsp?COMPTE_ACTIF=%s' % \ (compte_id_re.search(url_to_parse).groups()[0], compte_id_re.search(url_to_parse).groups()[1]) # account.label - tpl = cpt.xpath("./td[2]/a/text()")[0].split(' ') - account.label = unicode(' '.join(tpl[:2])) + account.label = cpt.xpath("./span/text()")[0].replace(u"\xa0", "").replace(',', '.').replace("EUR", "").replace("\n", "").replace("\t", "").replace(" ", "").replace(u"\xb0", '').replace(" ", "").replace('N', '') l.append(account)