diff --git a/modules/cragr/api/browser.py b/modules/cragr/api/browser.py index 11f4a2fa516606a8140e5dd8b5ac07d32bde3494..37b803e6ae399e040463a0f2fc1bfbe50b78b7a7 100644 --- a/modules/cragr/api/browser.py +++ b/modules/cragr/api/browser.py @@ -33,7 +33,7 @@ from weboob.tools.capabilities.bank.transactions import sorted_transactions from .pages import ( - LoginPage, LoggedOutPage, KeypadPage, SecurityPage, ContractsPage, AccountsPage, AccountDetailsPage, + LoginPage, LoggedOutPage, KeypadPage, SecurityPage, ContractsPage, FirstConnectionPage, AccountsPage, AccountDetailsPage, TokenPage, IbanPage, HistoryPage, CardsPage, CardHistoryPage, NetfincaRedirectionPage, PredicaRedirectionPage, PredicaInvestmentsPage, ProfilePage, ProfileDetailsPage, ProProfileDetailsPage, ) @@ -50,6 +50,7 @@ class CragrAPI(LoginBrowser): login_page = URL(r'particulier/acceder-a-mes-comptes.html$', LoginPage) keypad = URL(r'particulier/acceder-a-mes-comptes.authenticationKeypad.json', KeypadPage) security_check = URL(r'particulier/acceder-a-mes-comptes.html/j_security_check', SecurityPage) + first_connection = URL(r'.*/operations/interstitielles/premiere-connexion.html', FirstConnectionPage) logged_out = URL(r'.*', LoggedOutPage) token_page = URL(r'libs/granite/csrf/token.json', TokenPage) diff --git a/modules/cragr/api/pages.py b/modules/cragr/api/pages.py index 5b323680a78c364252043ccf12e6280765201185..8cfe987c10996d8066feef123fe6b8749c1286d2 100644 --- a/modules/cragr/api/pages.py +++ b/modules/cragr/api/pages.py @@ -25,6 +25,7 @@ import dateutil from weboob.browser.pages import HTMLPage, JsonPage, LoggedPage +from weboob.exceptions import ActionNeeded from weboob.capabilities import NotAvailable from weboob.capabilities.bank import ( Account, AccountOwnerType, Transaction, Investment, @@ -68,6 +69,13 @@ def is_here(self): return self.doc.xpath('//b[text()="FIN DE CONNEXION"]') +class FirstConnectionPage(LoggedPage, HTMLPage): + def on_load(self): + message = CleanText('//p[contains(text(), "votre première visite")]')(self.doc) + if message: + raise ActionNeeded(message) + + class SecurityPage(JsonPage): def get_accounts_url(self): return Dict('url')(self.doc)