From 5b5ce050e50c04ff84d4d9baaba5ac1378427435 Mon Sep 17 00:00:00 2001 From: Dorian Roly Date: Wed, 10 Jul 2019 13:43:53 +0200 Subject: [PATCH] [BforBank] Add capability CapProfile to the module I've implemented CapProfile to BforBank module. the module is now able to scrape the personal information of the user under profile information. I've applied the suggestions --- modules/bforbank/browser.py | 8 +++++++- modules/bforbank/module.py | 6 +++++- modules/bforbank/pages.py | 22 ++++++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/modules/bforbank/browser.py b/modules/bforbank/browser.py index 54bec9e1b2..536b17681d 100644 --- a/modules/bforbank/browser.py +++ b/modules/bforbank/browser.py @@ -30,7 +30,7 @@ LoginPage, ErrorPage, AccountsPage, HistoryPage, LoanHistoryPage, RibPage, LifeInsuranceList, LifeInsuranceIframe, LifeInsuranceRedir, BoursePage, CardHistoryPage, CardPage, UserValidationPage, BourseActionNeeded, - BourseDisconnectPage, + BourseDisconnectPage, ProfilePage, ) from .spirica_browser import SpiricaBrowser @@ -68,6 +68,7 @@ class BforbankBrowser(LoginBrowser): bourse_titre = URL(r'https://bourse.bforbank.com/netfinca-titres/servlet/com.netfinca.frontcr.navigation.Titre', BoursePage) # to get logout link bourse_disco = URL(r'https://bourse.bforbank.com/netfinca-titres/servlet/com.netfinca.frontcr.login.ContextTransferDisconnect', BourseDisconnectPage) + profile = URL(r'/espace-client/profil/informations', ProfilePage) def __init__(self, birthdate, username, password, *args, **kwargs): super(BforbankBrowser, self).__init__(username, password, *args, **kwargs) @@ -295,3 +296,8 @@ def leave_espace_bourse(self): self.location(self.bourse_titre.build()) self.location(self.page.get_logout_link()) self.location(self.page.get_relocation()) + + @need_login + def get_profile(self): + self.profile.go() + return self.page.get_profile() diff --git a/modules/bforbank/module.py b/modules/bforbank/module.py index a679eeb363..92260aff4b 100644 --- a/modules/bforbank/module.py +++ b/modules/bforbank/module.py @@ -21,6 +21,7 @@ from weboob.tools.backend import Module, BackendConfig from weboob.capabilities.bank import CapBankWealth, AccountNotFound from weboob.capabilities.base import find_object +from weboob.capabilities.profile import CapProfile from weboob.tools.value import ValueBackendPassword, ValueDate from .browser import BforbankBrowser @@ -28,7 +29,7 @@ __all__ = ['BforbankModule'] -class BforbankModule(Module, CapBankWealth): +class BforbankModule(Module, CapBankWealth, CapProfile): NAME = 'bforbank' DESCRIPTION = u'BforBank' MAINTAINER = u'Baptiste Delpey' @@ -62,3 +63,6 @@ def iter_history(self, account): def iter_investment(self, account): return self.browser.iter_investment(account) + + def get_profile(self): + return self.browser.get_profile() diff --git a/modules/bforbank/pages.py b/modules/bforbank/pages.py index 3b2504a5b1..1a2da3558f 100644 --- a/modules/bforbank/pages.py +++ b/modules/bforbank/pages.py @@ -30,6 +30,7 @@ from weboob.browser.pages import LoggedPage, HTMLPage, pagination, AbstractPage from weboob.browser.elements import method, ListElement, ItemElement, TableElement from weboob.capabilities.bank import Account +from weboob.capabilities.profile import Person from weboob.browser.filters.html import Link, Attr, TableCell from weboob.browser.filters.standard import ( CleanText, Regexp, Field, Map, CleanDecimal, Date, Format, @@ -386,3 +387,24 @@ def get_relocation(self): if link: m = link.group(1) return m + + +class ProfilePage(LoggedPage, HTMLPage): + @method + class get_profile(ItemElement): + klass = Person + + obj_birth_date = Date(CleanText('//td[text()="Date de naissance"]/following::td[1]')) + obj_name = CleanText('//div[contains(@class,"tab-pane")]/table/thead/tr/th') + obj_nationality = CleanText('//td[text()="Nationalité(s)"]/following::td[1]') + obj_family_situation = CleanText('//td[text()="Situation Familiale"]/following::td[1]') + obj_email = CleanText('//td[text()="Adresse e-mail"]/following::td[1]') + obj_phone = CleanText('//td[text()="Téléphone portable"]/following::td[1]//td[1]') + obj_country = CleanText('//td[text()="Pays"]/following::td[1]') + obj_socioprofessional_category = CleanText('//td[text()="Situation professionnelle"]/following::td[1]') + obj_address = Format( + '%s %s %s', + CleanText('//td[text()="Adresse"]/following::td[1]'), + CleanText('//td[text()="Code postal"]/following::td[1]'), + CleanText('//td[text()="Ville"]/following::td[1]') + ) -- GitLab