From 498d168a7f36571d52a8ab472fbd047174bc613c Mon Sep 17 00:00:00 2001 From: Xavier G Date: Mon, 22 Aug 2011 23:27:03 +0200 Subject: [PATCH] CrAgr: added Richard Genoud's patch handling "See 25 more" links. Add full history on account page: on CA centre france (and maybe others), there's no "next page" link but a "see 25 more" link. So, we have to expand the history before fetching results --- weboob/backends/cragr/browser.py | 12 ++++++++++++ weboob/backends/cragr/pages/accounts_list.py | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/weboob/backends/cragr/browser.py b/weboob/backends/cragr/browser.py index 48a744f0..c057596d 100644 --- a/weboob/backends/cragr/browser.py +++ b/weboob/backends/cragr/browser.py @@ -42,6 +42,7 @@ class Cragr(BaseBrowser): 'https://[^/]+/accounting/listAccounts': pages.AccountsList, 'https://[^/]+/accounting/listOperations': pages.AccountsList, 'https://[^/]+/accounting/showAccountDetail.+': pages.AccountsList, + 'https://[^/]+/accounting/showMoreAccountOperations.*': pages.AccountsList, } BaseBrowser.__init__(self, *args, **kwargs) @@ -98,7 +99,18 @@ class Cragr(BaseBrowser): page_url = account.link_id operations_count = 0 while (page_url): + # 1st, go on the account page self.location('https://%s%s' % (self.DOMAIN, page_url)) + + # then, expand all history + # (it's not a next page, but more operation on one page) + # tested on CA centre + while True: + history_url = self.page.expand_history_page_url() + if not history_url : + break + self.location(history_url) + for page_operation in self.page.get_history(operations_count): operations_count += 1 yield page_operation diff --git a/weboob/backends/cragr/pages/accounts_list.py b/weboob/backends/cragr/pages/accounts_list.py index 464bfe00..50abbc0e 100644 --- a/weboob/backends/cragr/pages/accounts_list.py +++ b/weboob/backends/cragr/pages/accounts_list.py @@ -115,6 +115,19 @@ class AccountsList(CragrBasePage): def get_transfer_target_accounts(self): return self.get_transfer_accounts('numCompteBeneficiaire') + def expand_history_page_url(self): + """ + When on a page dedicated to list the history of a specific account (see + is_account_page), returns the link to expand the history with 25 more results, + or False if the link is not present. + """ + # tested on CA centre france + a = self.document.xpath('/html/body//div[@class="navlink"]//a[contains(text(), "Voir les 25 suivants")]') + if not a: + return False + else: + return a[0].get('href', '') + def next_page_url(self): """ When on a page dedicated to list the history of a specific account (see