Commit e9ed2810 authored by Quentin Defenouillere's avatar Quentin Defenouillere Committed by Vincent A

[amundi] Handle bugs on CprInvestmentsPage

Some investments lead to a 404 (even on the website) and we have to
handle unavailable SRRI.
parent 682f8a02
......@@ -21,7 +21,9 @@ from __future__ import unicode_literals
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 @@ class AmundiBrowser(LoginBrowser):
# This method handles all the already encountered pages.
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
......@@ -314,11 +314,16 @@ class EresInvestmentPage(LoggedPage, HTMLPage):
class CprInvestmentPage(LoggedPage, HTMLPage):
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..."'
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