Commit 5b5ce050 authored by Dorian Roly's avatar Dorian Roly Committed by ntome

[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
parent 225775df
......@@ -30,7 +30,7 @@ from .pages import (
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 @@ class BforbankBrowser(LoginBrowser):
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()
......@@ -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 @@ from .browser import BforbankBrowser
__all__ = ['BforbankModule']
class BforbankModule(Module, CapBankWealth):
class BforbankModule(Module, CapBankWealth, CapProfile):
NAME = 'bforbank'
DESCRIPTION = u'BforBank'
MAINTAINER = u'Baptiste Delpey'
......@@ -62,3 +63,6 @@ class BforbankModule(Module, CapBankWealth):
def iter_investment(self, account):
return self.browser.iter_investment(account)
def get_profile(self):
return self.browser.get_profile()
......@@ -30,6 +30,7 @@ from weboob.exceptions import ActionNeeded
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 @@ class BourseDisconnectPage(LoggedPage, HTMLPage):
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]')
)
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