diff --git a/modules/axabanque/browser.py b/modules/axabanque/browser.py index 04b547a9a3d0bdcf41188cdf14d0c6c6e8048e01..6faa5ebab4df0c20af48651a58ae5087cc81c48f 100644 --- a/modules/axabanque/browser.py +++ b/modules/axabanque/browser.py @@ -56,7 +56,7 @@ ConfirmTransferPage, RecipientConfirmationPage, ScheduledTransfersPage, ScheduledTransferDetailsPage, ) -from .pages.document import DocumentsPage, DownloadPage +from .pages.document import DocumentsPage, DownloadPage, DocumentDetailsPage class AXABrowser(LoginBrowser): @@ -789,7 +789,7 @@ class AXAAssurance(AXABrowser): performance_monaxa = URL(r'https://monaxaweb-gp.axa.fr/MonAxa/ContratPerformance/', PerformanceMonAxaPage) documents_life_insurance = URL( - r'/content/espace-client/accueil/mes-documents/situations-de-contrats-assurance-vie.content-inner.din_SAVINGS_STATEMENT.html', + r'/content/espace-client/accueil/mes-documents/contrats.content-inner.din_POLICY.html', DocumentsPage ) documents_certificates = URL( @@ -804,9 +804,13 @@ class AXAAssurance(AXABrowser): r'/content/espace-client/accueil/mes-documents/avis-d-echeance.content-inner.din_PREMIUM_STATEMENT.html', DocumentsPage ) - + document_details = URL( + r'/content/ecc-popin-cards/technical/detailed/dam-document.content-inner', + DocumentDetailsPage + ) download = URL( r'/content/ecc-popin-cards/technical/detailed/download-document.downloadPdf.html', + r'/content/dam/axa/ecc/pdf', DownloadPage ) profile = URL(r'/content/ecc-popin-cards/transverse/userprofile.content-inner.html\?_=\d+', ProfilePage) @@ -943,9 +947,20 @@ def iter_documents(self, subscription): yield doc @need_login - def download_document(self, download_id): - self.download.go(data={'documentId': download_id}) - return self.page.content + def download_document(self, document): + # "On request" documents are not downloadable, they are sent by physical mail + if 'onrequest-document' in document.url: + return + # These documents have a direct download URL instead of a download ID. + elif 'dam-document' in document.url: + self.location(document.url) + document_url = self.page.get_download_url() + self.location(document_url) + return self.page.content + # These documents are obtained with a generic URL and a download ID as a parameter. + elif document._download_id: + self.download.go(data={'documentId': document._download_id}) + return self.page.content @need_login def get_profile(self): diff --git a/modules/axabanque/module.py b/modules/axabanque/module.py index 1cc14ae654617206d6068c93a499a4a7c7dd90c5..691907981c95f75efd40500d46a9e3b1baee5fa0 100644 --- a/modules/axabanque/module.py +++ b/modules/axabanque/module.py @@ -170,7 +170,7 @@ def iter_documents(self, subscription): def download_document(self, document): if not isinstance(document, Document): document = self.get_document(document) - return self.browser.download_document(document._download_id) + return self.browser.download_document(document) def iter_resources(self, objs, split_path): if Account in objs: diff --git a/modules/axabanque/pages/document.py b/modules/axabanque/pages/document.py index a5dde8698dd31b2a61443bc9c1b03ec9306339f2..65d21d44e9960184b5e8efd72977ec2a4111616d 100644 --- a/modules/axabanque/pages/document.py +++ b/modules/axabanque/pages/document.py @@ -20,8 +20,10 @@ from __future__ import unicode_literals from woob.browser.pages import HTMLPage, LoggedPage +from woob.browser.filters.html import Attr from woob.browser.filters.standard import CleanText, Env, Regexp, Format, Date from woob.browser.elements import ListElement, ItemElement, method +from woob.capabilities import NotAvailable from woob.capabilities.bill import Document from woob.tools.date import parse_french_date @@ -37,7 +39,7 @@ class item(ItemElement): obj_id = Format( '%s_%s', Env('subid'), - Regexp(CleanText('./@data-module-open-link--link'), '#/details/(.*)'), + Regexp(Attr('.', 'data-module-open-link--link'), r'#/details/(.*)'), ) obj_format = 'pdf' # eg when formatted (not complete list): @@ -50,12 +52,18 @@ class item(ItemElement): CleanText('.//div[@class="sticker-content"]//strong'), CleanText('.//p[@class="contract-info"]'), ) - obj_date = Date(CleanText('.//p[@class="card-date"]'), parse_func=parse_french_date) + obj_date = Date(CleanText('.//p[@class="card-date"]'), parse_func=parse_french_date, default=NotAvailable) obj_type = 'document' - obj__download_id = Regexp(CleanText('./@data-url'), r'.did_(.*?)\.') + obj_url = Attr('.', 'data-url') + obj__download_id = Regexp(Attr('.', 'data-url'), r'.[dp]id_(.*?)\.', default=None) class DownloadPage(LoggedPage, HTMLPage): def create_document(self): form = self.get_form(xpath='//form[has-class("form-download-pdf")]') form.submit() + + +class DocumentDetailsPage(LoggedPage, HTMLPage): + def get_download_url(self): + return Attr('//button', 'data-module-open-link--link')(self.doc)