From a66bc85b459a99af45a5150f07a757c47498e014 Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Tue, 12 Mar 2013 14:49:50 +0100 Subject: [PATCH] get more history --- modules/fortuneo/browser.py | 10 ++++++++++ modules/fortuneo/pages/accounts_list.py | 16 +++++----------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/modules/fortuneo/browser.py b/modules/fortuneo/browser.py index a9639d27..481743fa 100644 --- a/modules/fortuneo/browser.py +++ b/modules/fortuneo/browser.py @@ -19,6 +19,9 @@ # along with weboob. If not, see . +from datetime import date +from dateutil.relativedelta import relativedelta + from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword from .pages.login import LoginPage @@ -80,6 +83,13 @@ class Fortuneo(BaseBrowser): def get_history(self, account): self.location(account._link_id) + + self.select_form(name='ConsultationHistoriqueOperationsForm') + self.set_all_readonly(False) + self['dateRechercheDebut'] = (date.today() - relativedelta(years=1)).strftime('%d/%m/%Y') + self['nbrEltsParPage'] = '100' + self.submit() + return self.page.get_operations(account) def get_accounts_list(self): diff --git a/modules/fortuneo/pages/accounts_list.py b/modules/fortuneo/pages/accounts_list.py index 87092226..de4b1017 100644 --- a/modules/fortuneo/pages/accounts_list.py +++ b/modules/fortuneo/pages/accounts_list.py @@ -57,20 +57,20 @@ class AccountHistoryPage(BasePage): """history, see http://docs.weboob.org/api/capabilities/bank.html?highlight=transaction#weboob.capabilities.bank.Transaction""" # TODO need to rewrite that with FrenchTransaction class http://tinyurl.com/6lq4r9t - operations = [] tables = self.document.findall(".//*[@id='tabHistoriqueOperations']/tbody/tr") if len(tables) == 0: - return [] + return for i in range(len(tables)): - operation = Transaction(len(operations)) + operation = Transaction(i) operation.type = 0 operation.category = NotAvailable date_oper = tables[i].xpath("./td[2]/text()")[0] date_val = tables[i].xpath("./td[3]/text()")[0] label = tables[i].xpath("./td[4]/text()")[0] + label = re.sub(r'[ \xa0]+', ' ', label).strip() amount = tables[i].xpath("./td[5]/text() | ./td[6]/text()") operation.parse(date=date_val, raw=label) @@ -83,9 +83,7 @@ class AccountHistoryPage(BasePage): operation.set_amount(amount) - operations.append(operation) - - return operations + yield operation class AccountsList(BasePage): def on_loaded(self): @@ -122,8 +120,6 @@ class AccountsList(BasePage): return len(form) > 0 def get_list(self): - l = [] - for cpt in self.document.xpath(".//*[@class='synthese_id_compte']"): account = Account() @@ -158,9 +154,7 @@ class AccountsList(BasePage): temp_label = cpt.xpath('./text()')[1].replace(u'-\xa0', '').replace("\n", "").replace("\t", "") account.label = " ".join(temp_label.split(" ")[:2]) - l.append(account) - - return l + yield account class GlobalAccountsList(BasePage): pass