diff --git a/modules/amundi/browser.py b/modules/amundi/browser.py index 41f80cf1b40b732bce89c3b4dd59f4cb7d664059..79e2b642e6dc734618072737d99f26f68b13d090 100644 --- a/modules/amundi/browser.py +++ b/modules/amundi/browser.py @@ -21,7 +21,9 @@ from weboob.browser import URL, LoginBrowser, need_login from weboob.exceptions import BrowserIncorrectPassword -from weboob.browser.exceptions import ClientError, ServerError +from weboob.browser.exceptions import ( + ClientError, ServerError, BrowserHTTPNotFound, +) from weboob.capabilities.base import empty, NotAvailable from .pages import ( @@ -138,8 +140,9 @@ def fill_investment_details(self, inv): # This method handles all the already encountered pages. try: self.location(inv._details_url) - except ServerError: - # Some URLs return a 500 even on the website + except (ServerError, BrowserHTTPNotFound): + # Some URLs return a 500 or a 404 even on the website + self.logger.warning('Details are not available for this investment.') inv.asset_category = NotAvailable inv.recommended_period = NotAvailable return inv diff --git a/modules/amundi/pages.py b/modules/amundi/pages.py index 1254ca37f27b440556fa9c837c79c7c947d46f66..623d545395c2d2561684ba388243ce458583ae31 100644 --- a/modules/amundi/pages.py +++ b/modules/amundi/pages.py @@ -314,11 +314,16 @@ def obj_performance_history(self): class CprInvestmentPage(LoggedPage, HTMLPage): @method class fill_investment(ItemElement): - obj_srri = CleanText('//span[@class="active"]', default=NotAvailable) # Text headers can be in French or in English obj_asset_category = Title('//div[contains(text(), "Classe d\'actifs") or contains(text(), "Asset class")]//strong', default=NotAvailable) obj_recommended_period = Title('//div[contains(text(), "Durée recommandée") or contains(text(), "Recommended duration")]//strong', default=NotAvailable) + def obj_srri(self): + srri = CleanText('//span[@class="active"]')(self) + # 'srri' can sometimes be an empty string, so we keep + # the value scraped on the Amundi website + return srri or self.obj.srri + def get_performance_url(self): js_script = CleanText('//script[@language="javascript"]')(self.doc) # beurk # Extract performance URL from a string such as 'Product.init(false,"/particuliers..."'