The new woob repository is here: https://gitlab.com/woob/woob. This gitlab will be removed soon.

The new woob repository is here: https://gitlab.com/woob/woob. This gitlab will be removed soon.

Commit f6fbf2d6 authored by Christophe François's avatar Christophe François Committed by Vincent A

[wiseed] Handle new URLs for bonds, stocks and equities

The tables for bonds, stocks and equities are not directly on the
investments page anymore. They are loaded using JS by calling new URLs.

Closes: 34367@zendesk
parent d102d028
......@@ -22,7 +22,10 @@
from woob.browser import LoginBrowser, need_login, URL, StatesMixin
from woob.capabilities.bank import Account
from .pages import LoginPage, LandPage, InvestPage
from .pages import (
LoginPage, LandPage, InvestPage, StocksPage, BondsPage,
EquitiesPage,
)
# TODO implement documents and profile
......@@ -31,9 +34,12 @@ class WiseedBrowser(LoginBrowser, StatesMixin):
BASEURL = 'https://www.wiseed.com'
TIMEOUT = 120
login = URL('/fr/connexion', LoginPage)
landing = URL('/fr/projets-en-financement', LandPage)
invests = URL('/fr/compte/portefeuille', InvestPage)
login = URL(r'/fr/connexion', LoginPage)
landing = URL(r'/fr/projets-en-financement', LandPage)
invests = URL(r'/fr/compte/portefeuille$', InvestPage)
stocks = URL(r'/fr/compte/portefeuille/actions', StocksPage)
bonds = URL(r'/fr/compte/portefeuille/obligations', BondsPage)
equities = URL(r'/fr/compte/portefeuille/titres-participatifs', EquitiesPage)
def do_login(self):
self.login.go()
......@@ -65,11 +71,17 @@ def iter_investment(self):
yield self.page.get_liquidities()
for inv in self.page.iter_funded_bond():
for inv in self.page.iter_funding():
yield inv
for inv in self.page.iter_funded_stock():
self.bonds.go()
for inv in self.page.iter_funded_bonds():
yield inv
for inv in self.page.iter_funding():
self.stocks.go()
for inv in self.page.iter_funded_stocks():
yield inv
self.equities.go()
for inv in self.page.iter_funded_equities():
yield inv
......@@ -67,66 +67,79 @@ def get_liquidities(self):
return create_french_liquidity(value)
@method
class iter_funded_stock(TableElement):
item_xpath = '//table[@id="portefeuilleAction"]/tbody/tr'
class iter_funding(TableElement):
def find_elements(self):
for el in self.page.doc.xpath('//div[has-class("panel")]'):
if 'souscription(s) en cours' in CleanText('.')(el):
for sub in el.xpath('.//table[has-class("portefeuille-liste") and not(@id)]/tbody/tr'):
yield sub
return
head_xpath = '//table[@id="portefeuilleAction"]/thead//th'
col_bought = 'Vous avez investi'
col_label = 'Investissement dans'
col_valuation = 'Valeur estimée à date'
col_diff_ratio = 'Coef. de performance intermediaire'
head_xpath = '//table[has-class("portefeuille-liste") and not(@id)]/thead//th'
col_label = 'Opération / Cible'
col_details = 'Détails'
class item(ItemElement):
klass = Investment
obj_label = CleanText(TableCell('label'))
# text is "0000000000000100 100,00 €", wtf
obj_valuation = CleanDecimal.SI(
Regexp(CleanText(TableCell('valuation')), r'^000(\d+)\b')
# Can be "100,00 € + Frais de 0,90 €" or "€100.00"
obj_valuation = Coalesce(
CleanDecimal.French(Regexp(CleanText(TableCell('details')), r'^(.*?) €', default=None), default=None),
CleanDecimal.US(Regexp(CleanText(TableCell('details')), r'^€([^ ]+)', default=None), default=None),
)
class FundItemElement(ItemElement):
klass = Investment
obj_label = CleanText(TableCell('label'))
# text is "0000000000000100 100,00 €"
obj_valuation = CleanDecimal.SI(
Regexp(CleanText(TableCell('bought')), r'^000(\d+)\b')
)
class StocksPage(LoggedPage, HTMLPage):
@method
class iter_funded_stocks(TableElement):
item_xpath = '//table[@id="table-portefeuille-actions"]/tbody/tr'
head_xpath = '//table[@id="table-portefeuille-actions"]/thead//th'
col_bought = 'Vous avez investi'
col_label = 'Investissement dans'
col_valuation = 'Valeur estimée à date'
col_diff_ratio = 'Coef. de performance intermediaire'
class item(FundItemElement):
obj_diff_ratio = CleanDecimal.SI(
Regexp(CleanText(TableCell('diff_ratio')), r'^000(\d+)\b')
)
class BondsPage(LoggedPage, HTMLPage):
@method
class iter_funded_bond(TableElement):
item_xpath = '//div[@id="panel-OBLIGATIONS"]//table[has-class("portefeuille-liste")]/tbody/tr'
class iter_funded_bonds(TableElement):
item_xpath = '//table[@id="table-portefeuille-obligations"]/tbody/tr'
head_xpath = '//table[@id="table-portefeuille-obligations"]/thead//th'
head_xpath = '//div[@id="panel-OBLIGATIONS"]//table[has-class("portefeuille-liste")]/thead//th'
col_bought = 'Vous avez investi'
col_label = 'Investissement dans'
class item(ItemElement):
klass = Investment
obj_label = CleanText(TableCell('label'))
class item(FundItemElement):
pass
obj_valuation = CleanDecimal.SI(
Regexp(CleanText(TableCell('bought')), r'^000(\d+)\b')
)
class EquitiesPage(LoggedPage, HTMLPage):
@method
class iter_funding(TableElement):
def find_elements(self):
for el in self.page.doc.xpath('//div[has-class("panel")]'):
if 'souscription(s) en cours' in CleanText('.')(el):
for sub in el.xpath('.//table[has-class("portefeuille-liste") and not(@id)]/tbody/tr'):
yield sub
return
class iter_funded_equities(TableElement):
item_xpath = '//table[@id="table-portefeuille-titres-participatifs"]/tbody/tr'
head_xpath = '//table[@id="table-portefeuille-titres-participatifs"]/thead//th'
head_xpath = '//table[has-class("portefeuille-liste") and not(@id)]/thead//th'
col_label = 'Opération / Cible'
col_details = 'Détails'
class item(ItemElement):
klass = Investment
obj_label = CleanText(TableCell('label'))
col_bought = 'Vous avez investi'
col_label = 'Investissement dans'
# Can be "100,00 € + Frais de 0,90 €" or "€100.00"
obj_valuation = Coalesce(
CleanDecimal.French(Regexp(CleanText(TableCell('details')), r'^(.*?) €', default=None), default=None),
CleanDecimal.US(Regexp(CleanText(TableCell('details')), r'^€([^ ]+)', default=None), default=None),
)
class item(FundItemElement):
pass
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