Commit 82b859ec authored by Célande Adrien's avatar Célande Adrien Committed by Romain Bignon

[banquepopulaire] retrieve missing coming

One web page of coming transactions was not scraped
because we considered that there is only one page at a time.

Now the number of coming receipts are counts.
This count is used for the ids of `sel_tbl1` in the form to retrieve the page.

Closes: 10012@zendesk
parent c70f0ac9
...@@ -312,57 +312,68 @@ class BanquePopulaire(LoginBrowser): ...@@ -312,57 +312,68 @@ class BanquePopulaire(LoginBrowser):
@retry(LoggedOut) @retry(LoggedOut)
@need_login @need_login
def get_history(self, account, coming=False): def get_history(self, account, coming=False):
account = self.get_account( def get_history_by_receipt(account, coming, sel_tbl1=None):
account = self.get_account(
if account is None: if account is None:
raise BrowserUnavailable() raise BrowserUnavailable()
if account._invest_params or ('TIT') and account._params): if account._invest_params or ('TIT') and account._params):
if not coming: if not coming:
for tr in self.get_invest_history(account): for tr in self.get_invest_history(account):
yield tr yield tr
return return
if coming: if coming:
params = account._coming_params params = account._coming_params
else: else:
params = account._params params = account._params
if params is None: if params is None:
return return
params['token'] =['token'])
params['token'] =['token']) if sel_tbl1 != None:
params['attribute($SEL_$tbl1)'] = str(sel_tbl1)
self.location(self.absurl('/cyber/internet/', base=True), data=params) self.location(self.absurl('/cyber/internet/', base=True), data=params)
if not or self.error_page.is_here() or if not or self.error_page.is_here() or
return return
# Sort by values dates (see comment in TransactionsPage.get_history) # Sort by values dates (see comment in TransactionsPage.get_history)
if len('//a[@id="tcl4_srt"]')) > 0: if len('//a[@id="tcl4_srt"]')) > 0:
form ='myForm') form ='myForm')
form.url = self.absurl('/cyber/internet/') form.url = self.absurl('/cyber/internet/')
params['token'] =['token']) params['token'] =['token'])
form.submit() form.submit()
transactions_next_page = True transactions_next_page = True
while transactions_next_page: while transactions_next_page:
assert self.transactions_page.is_here() assert self.transactions_page.is_here()
transaction_list =, coming) transaction_list =, coming)
for tr in transaction_list: for tr in transaction_list:
# Add information about GoCardless # Add information about GoCardless
if 'GoCardless' in tr.label and tr._has_link: if 'GoCardless' in tr.label and tr._has_link:
self.set_gocardless_transaction_details(tr) self.set_gocardless_transaction_details(tr)
yield tr yield tr
next_params = next_params =
# Go to the next transaction page only if it exists: # Go to the next transaction page only if it exists:
if next_params is None: if next_params is None:
transactions_next_page = False transactions_next_page = False
else: else:
self.location('/cyber/internet/', params=next_params) self.location('/cyber/internet/', params=next_params)
if coming and account._coming_count:
for i in range(account._coming_count):
for tr in get_history_by_receipt(account, coming, sel_tbl1=i):
yield tr
for tr in get_history_by_receipt(account, coming):
yield tr
@need_login @need_login
def go_investments(self, account, get_account=False): def go_investments(self, account, get_account=False):
...@@ -554,6 +554,7 @@ class AccountsPage(LoggedPage, MyHTMLPage): ...@@ -554,6 +554,7 @@ class AccountsPage(LoggedPage, MyHTMLPage):
account._next_debit = None account._next_debit = None
account._params = None account._params = None
account._coming_params = None account._coming_params = None
account._coming_count = None
account._invest_params = None account._invest_params = None
if balance != u'' and len(tds[3].xpath('.//a')) > 0: if balance != u'' and len(tds[3].xpath('.//a')) > 0:
account._params = params.copy() account._params = params.copy()
...@@ -634,6 +635,7 @@ class CardsPage(LoggedPage, MyHTMLPage): ...@@ -634,6 +635,7 @@ class CardsPage(LoggedPage, MyHTMLPage):
account._coming_params = params.copy() account._coming_params = params.copy()
account._coming_params['dialogActionPerformed'] = 'SELECTION_ENCOURS_CARTE' account._coming_params['dialogActionPerformed'] = 'SELECTION_ENCOURS_CARTE'
account._coming_params['attribute($SEL_$%s)' % tr.attrib['id'].split('_')[0]] = tr.attrib['id'].split('_', 1)[1] account._coming_params['attribute($SEL_$%s)' % tr.attrib['id'].split('_')[0]] = tr.attrib['id'].split('_', 1)[1]
account._coming_count = len(self.doc.xpath('//table[@id="tbl1"]/tbody/tr/td[5]/span[not(contains(text(), "(1)"))]'))
elif account is None: elif account is None:
raise BrokenPageError('Unable to find accounts on cards page') raise BrokenPageError('Unable to find accounts on cards page')
else: else:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment