investment banquepopulaire
This commit is contained in:
parent
21e507a99e
commit
39aba3eb8f
3 changed files with 57 additions and 2 deletions
|
|
@ -23,7 +23,7 @@ import urllib
|
|||
from weboob.deprecated.browser import Browser, BrowserIncorrectPassword, BrokenPageError
|
||||
|
||||
from .pages import LoginPage, IndexPage, AccountsPage, AccountsFullPage, CardsPage, TransactionsPage, \
|
||||
UnavailablePage, RedirectPage, HomePage, Login2Page
|
||||
UnavailablePage, RedirectPage, HomePage, Login2Page, InvestmentPage
|
||||
|
||||
|
||||
__all__ = ['BanquePopulaire']
|
||||
|
|
@ -52,6 +52,7 @@ class BanquePopulaire(Browser):
|
|||
'https://[^/]+/portailinternet/Pages/default.aspx': HomePage,
|
||||
'https://[^/]+/portailinternet/Transactionnel/Pages/CyberIntegrationPage.aspx': HomePage,
|
||||
'https://[^/]+/WebSSO_BP/_(?P<bankid>\d+)/index.html\?transactionID=(?P<transactionID>.*)': Login2Page,
|
||||
'https://www.linebourse.fr/Portefeuille': InvestmentPage,
|
||||
}
|
||||
|
||||
def __init__(self, website, *args, **kwargs):
|
||||
|
|
@ -176,3 +177,17 @@ class BanquePopulaire(Browser):
|
|||
return
|
||||
|
||||
self.location(self.buildurl('/cyber/internet/Page.do', **next_params))
|
||||
|
||||
def get_investment(self, account):
|
||||
account = self.get_account(account.id)
|
||||
params = account._params
|
||||
if params is None:
|
||||
return
|
||||
params['token'] = self.page.build_token(params['token'])
|
||||
self.location('/cyber/internet/ContinueTask.do', urllib.urlencode(params))
|
||||
params = self.page.get_investment_page_params()
|
||||
if params:
|
||||
self.open('https://www.linebourse.fr/ReroutageSJR', urllib.urlencode(params))
|
||||
self.location('https://www.linebourse.fr/Portefeuille')
|
||||
return self.page.get_investments()
|
||||
|
||||
|
|
|
|||
|
|
@ -89,3 +89,7 @@ class BanquePopulaireModule(Module, CapBank):
|
|||
def iter_coming(self, account):
|
||||
with self.browser:
|
||||
return self.browser.get_history(account, coming=True)
|
||||
|
||||
def iter_investment(self, account):
|
||||
with self.browser:
|
||||
return self.browser.get_investment(account)
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ from mechanize import Cookie, FormNotFoundError
|
|||
|
||||
from weboob.exceptions import BrowserUnavailable, BrowserIncorrectPassword
|
||||
from weboob.deprecated.browser import Page as _BasePage, BrokenPageError
|
||||
from weboob.capabilities.bank import Account
|
||||
from weboob.capabilities.bank import Account, Investment
|
||||
from weboob.tools.capabilities.bank.transactions import FrenchTransaction
|
||||
from weboob.tools.json import json
|
||||
|
||||
|
|
@ -627,3 +627,39 @@ class TransactionsPage(BasePage):
|
|||
return True
|
||||
|
||||
return False
|
||||
|
||||
def get_investment_page_params(self):
|
||||
script = self.document.xpath('//body')[0].attrib['onload']
|
||||
params = {}
|
||||
for key, value in re.findall(r"key:'(?P<key>SJRToken)'\,value:'(?P<value>.*?)'}", script, re.MULTILINE):
|
||||
params[key] = value
|
||||
return params
|
||||
|
||||
|
||||
class InvestmentPage(_BasePage):
|
||||
COL_LABEL = 0
|
||||
COL_QUANTITY = 1
|
||||
COL_UNITVALUE = 2
|
||||
COL_VALUATION = 3
|
||||
COL_UNITPRICE = 4
|
||||
COL_PERF_PERCENT = 5
|
||||
COL_PERF = 6
|
||||
def get_investments(self):
|
||||
for line in self.document.xpath('//table[contains(@summary, "Contenu")]/tbody/tr[@class="color4"]'):
|
||||
cols1 = line.findall('td')
|
||||
cols2 = line.xpath('./following-sibling::tr')[0].findall('td')
|
||||
|
||||
inv = Investment()
|
||||
inv.label = self.parser.tocleanstring(cols1[self.COL_LABEL].xpath('.//span')[0])
|
||||
inv.code = self.parser.tocleanstring(cols1[self.COL_LABEL].xpath('./a')[0]).split(' ')[-1]
|
||||
inv.quantity = self.parse_decimal(cols2[self.COL_QUANTITY])
|
||||
inv.unitprice = self.parse_decimal(cols2[self.COL_UNITPRICE])
|
||||
inv.unitvalue = self.parse_decimal(cols2[self.COL_UNITVALUE])
|
||||
inv.valuation = self.parse_decimal(cols2[self.COL_VALUATION])
|
||||
inv.diff = self.parse_decimal(cols2[self.COL_PERF])
|
||||
|
||||
yield inv
|
||||
|
||||
def parse_decimal(self, string):
|
||||
value = self.parser.tocleanstring(string)
|
||||
return Decimal(Transaction.clean_amount(value))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue