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
This commit is contained in:
parent
7f3c4be18b
commit
498d168a7f
2 changed files with 25 additions and 0 deletions
|
|
@ -42,6 +42,7 @@ class Cragr(BaseBrowser):
|
||||||
'https://[^/]+/accounting/listAccounts': pages.AccountsList,
|
'https://[^/]+/accounting/listAccounts': pages.AccountsList,
|
||||||
'https://[^/]+/accounting/listOperations': pages.AccountsList,
|
'https://[^/]+/accounting/listOperations': pages.AccountsList,
|
||||||
'https://[^/]+/accounting/showAccountDetail.+': pages.AccountsList,
|
'https://[^/]+/accounting/showAccountDetail.+': pages.AccountsList,
|
||||||
|
'https://[^/]+/accounting/showMoreAccountOperations.*': pages.AccountsList,
|
||||||
}
|
}
|
||||||
BaseBrowser.__init__(self, *args, **kwargs)
|
BaseBrowser.__init__(self, *args, **kwargs)
|
||||||
|
|
||||||
|
|
@ -98,7 +99,18 @@ class Cragr(BaseBrowser):
|
||||||
page_url = account.link_id
|
page_url = account.link_id
|
||||||
operations_count = 0
|
operations_count = 0
|
||||||
while (page_url):
|
while (page_url):
|
||||||
|
# 1st, go on the account page
|
||||||
self.location('https://%s%s' % (self.DOMAIN, page_url))
|
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):
|
for page_operation in self.page.get_history(operations_count):
|
||||||
operations_count += 1
|
operations_count += 1
|
||||||
yield page_operation
|
yield page_operation
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,19 @@ class AccountsList(CragrBasePage):
|
||||||
def get_transfer_target_accounts(self):
|
def get_transfer_target_accounts(self):
|
||||||
return self.get_transfer_accounts('numCompteBeneficiaire')
|
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):
|
def next_page_url(self):
|
||||||
"""
|
"""
|
||||||
When on a page dedicated to list the history of a specific account (see
|
When on a page dedicated to list the history of a specific account (see
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue