diff --git a/modules/creditdunord/browser.py b/modules/creditdunord/browser.py index 7d24f9ac8eea3fe23f937f9b2aa6dc4bda663c5e..b609f77126f99c74b19638d2e7b5ffec8c2d949f 100644 --- a/modules/creditdunord/browser.py +++ b/modules/creditdunord/browser.py @@ -27,7 +27,7 @@ from .pages import ( LoginPage, ProfilePage, AccountTypePage, AccountsPage, ProAccountsPage, TransactionsPage, IbanPage, RedirectPage, EntryPage, AVPage, ProIbanPage, - ProTransactionsPage, LabelsPage, RgpdPage, LoginConfirmPage, + ProTransactionsPage, LabelsPage, RgpdPage, LoginConfirmPage, NotFoundPage, ) @@ -41,7 +41,8 @@ class CreditDuNordBrowser(LoginBrowser): LoginPage) login_confirm = URL(r'/sec/vk/authent.json', LoginConfirmPage) labels_page = URL(r'/icd/zco/data/public-menu.json', LabelsPage) - redirect = URL('/swm/redirectCDN.html', RedirectPage) + redirect = URL('/swm/redirectCDN.html', '/swm/errorWebCDN.html', RedirectPage) + not_found = URL('/sites/erreur-404', NotFoundPage) entrypage = URL('/icd/zco/#zco', EntryPage) multitype_av = URL('/vos-comptes/IPT/appmanager/transac/professionnels\?_nfpb=true&_eventName=onRestart&_pageLabel=synthese_contrats_assurance_vie', AVPage) loans = URL(r'/vos-comptes/IPT/appmanager/transac/(?P.*)\?_nfpb=true&_eventName=onRestart&_pageLabel=(?P(creditPersoImmobilier|credit_?_en_cours))', ProAccountsPage) @@ -91,8 +92,9 @@ def do_login(self): def _iter_accounts(self): owner_name = self.get_profile().name.upper() self.loans.go(account_type=self.account_type, loans_page_label=self.loans_page_label) - for a in self.page.get_list(): - yield a + if self.loans.is_here(): + for a in self.page.get_list(): + yield a self.accounts.go(account_type=self.account_type, accounts_page_label=self.accounts_page_label) self.multitype_av.go() if self.multitype_av.is_here(): diff --git a/modules/creditdunord/pages.py b/modules/creditdunord/pages.py index 57f979949ad19afc95b796f93d92debb0c30b7a2..bbf0912b5e61c3e38b651b9b2477c66cb1dd9547 100755 --- a/modules/creditdunord/pages.py +++ b/modules/creditdunord/pages.py @@ -107,7 +107,6 @@ def get_error(self): CleanText('//div[has-class("x-attentionErreur")]/b')(self.doc) - class RedirectPage(HTMLPage): def on_load(self): link = Regexp(CleanText('//script'), 'href="(.*)"', default='')(self.doc) @@ -115,6 +114,19 @@ def on_load(self): self.browser.location(link) +class NotFoundPage(HTMLPage): + """ + Attempt to access to ProAccountsPage can lead + instead to RedirectPage, leading this page. + It is a code 200 request but bear a 'erreur-404' in the URL + We need to pass through not to block the connection. + This happens only on certain connections as a wrongly activated + security feature of the server, + when there is no accounts on the aimed page. + """ + pass + + class EntryPage(LoggedPage, HTMLErrorPage): pass