From 7d91ba3586b89a3fe3c2986ee45bd2e31b22b0ae Mon Sep 17 00:00:00 2001 From: Quentin Defenouillere Date: Fri, 3 Jul 2020 16:44:03 +0200 Subject: [PATCH] [s2e] Handle 503 errors when fetching Investment details Currently the BNPPERE website does not work really well and the access to investment details returns 503 errors (even when clicking on the button on the website). We handle it with serverError. --- modules/s2e/browser.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/s2e/browser.py b/modules/s2e/browser.py index 3a1a4f43c8..52cee0dcc4 100644 --- a/modules/s2e/browser.py +++ b/modules/s2e/browser.py @@ -25,6 +25,7 @@ from weboob.browser import LoginBrowser, URL, need_login, StatesMixin from weboob.exceptions import BrowserIncorrectPassword, ActionNeeded, NoAccountsException +from weboob.browser.exceptions import ServerError from weboob.capabilities.wealth import Investment from weboob.tools.capabilities.bank.investments import is_isin_valid @@ -209,7 +210,13 @@ def update_investments(self, investments): # From the current URL, which has the format: # https://optimisermon.epargne-retraite-entreprises.bnpparibas.com/Mes-Supports/11111/QS0002222T5 # We can extract the investment ISIN code and use it to call routes of the BNP Wealth API - self.location(inv._link) + try: + self.location(inv._link) + except ServerError: + # For some connections, this request returns a 503 even on the website + self.logger.warning('Server returned a Server Error when trying to fetch investment performances.') + continue + m = re.search(r'Mes-Supports/(.*)/(.*)', self.url) if m: if is_isin_valid(m.group(2)): -- GitLab