Fix bp backend (closes #621)
This commit is contained in:
parent
66faba38de
commit
99646e40d9
7 changed files with 59 additions and 81 deletions
|
|
@ -20,7 +20,8 @@ from datetime import datetime
|
||||||
|
|
||||||
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword, BrowserBanned
|
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword, BrowserBanned
|
||||||
|
|
||||||
from .pages import LoginPage, LoggedPage, CookiePage, AccountList, AccountHistory, BadLoginPage, AccountDesactivate, \
|
from .pages import LoginPage, Initident, CheckPassword, repositionnerCheminCourant, BadLoginPage, AccountDesactivate, \
|
||||||
|
AccountList, AccountHistory, \
|
||||||
TransferChooseAccounts, CompleteTransfer, TransferConfirm, TransferSummary
|
TransferChooseAccounts, CompleteTransfer, TransferConfirm, TransferSummary
|
||||||
|
|
||||||
from weboob.capabilities.bank import Transfer
|
from weboob.capabilities.bank import Transfer
|
||||||
|
|
@ -33,19 +34,23 @@ class BPBrowser(BaseBrowser):
|
||||||
DOMAIN = 'voscomptesenligne.labanquepostale.fr'
|
DOMAIN = 'voscomptesenligne.labanquepostale.fr'
|
||||||
PROTOCOL = 'https'
|
PROTOCOL = 'https'
|
||||||
ENCODING = None # refer to the HTML encoding
|
ENCODING = None # refer to the HTML encoding
|
||||||
PAGES = {r'.*wsost/OstBrokerWeb/loginform.*': LoginPage,
|
PAGES = {r'.*wsost/OstBrokerWeb/loginform.*' : LoginPage,
|
||||||
r'.*voscomptes/canalXHTML/identif\.ea.*': LoggedPage,
|
r'.*authentification/repositionnerCheminCourant-identif.ea' : repositionnerCheminCourant,
|
||||||
r'.*voscomptes/canalXHTML/releve/syntheseAssurancesEtComptes\.ea': CookiePage,
|
r'.*authentification/initialiser-identif.ea' : Initident,
|
||||||
r'.*voscomptes/canalXHTML/releve/liste_comptes\.jsp': AccountList,
|
r'.*authentification/verifierMotDePasse-identif.ea' : CheckPassword,
|
||||||
r'.*canalXHTML/relevesCCP/.*': AccountHistory,
|
|
||||||
r'.*canalXHTML/relevesEpargnes/.*': AccountHistory,
|
|
||||||
r'.*ost/messages\.CVS\.html\?param=0x132120c8.*' : BadLoginPage,
|
|
||||||
r'.*ost/messages\.CVS\.html\?param=0x132120cb.*' : AccountDesactivate,
|
|
||||||
|
|
||||||
r'.*/virementsafran/aiguillage/saisieComptes\.ea.*': TransferChooseAccounts,
|
r'.*synthese_assurancesEtComptes/afficheSynthese-synthese\.ea' : AccountList,
|
||||||
r'.*/virementsafran/aiguillage/2-saisieComptes\.ea.*' : CompleteTransfer,
|
|
||||||
r'.*/virementsafran/virementnational/2-virementNational\.ea.*' : TransferConfirm,
|
r'.*CCP/releves_ccp/releveCPP-releve_ccp\.ea' : AccountHistory,
|
||||||
r'.*/virementsafran/virementnational/4-virementNational\.ea.*' : TransferSummary,
|
r'.*CNE/releveCNE/releveCNE-releve_cne\.ea' : AccountHistory,
|
||||||
|
|
||||||
|
r'.*/virementSafran_aiguillage/init-saisieComptes\.ea' : TransferChooseAccounts,
|
||||||
|
r'.*/virementSafran_aiguillage/formAiguillage-saisieComptes\.ea' : CompleteTransfer,
|
||||||
|
r'.*/virementSafran_national/validerVirementNational-virementNational.ea' : TransferConfirm,
|
||||||
|
r'.*/virementSafran_national/confirmerVirementNational-virementNational.ea' : TransferSummary,
|
||||||
|
|
||||||
|
r'.*ost/messages\.CVS\.html\?param=0x132120c8.*' : BadLoginPage,
|
||||||
|
r'.*ost/messages\.CVS\.html\?param=0x132120cb.*' : AccountDesactivate,
|
||||||
}
|
}
|
||||||
|
|
||||||
def home(self):
|
def home(self):
|
||||||
|
|
@ -69,16 +74,12 @@ class BPBrowser(BaseBrowser):
|
||||||
raise BrowserBanned()
|
raise BrowserBanned()
|
||||||
|
|
||||||
def get_accounts_list(self):
|
def get_accounts_list(self):
|
||||||
self.location('https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/authentification/'
|
self.location("https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/comptesCommun/synthese_assurancesEtComptes/afficheSynthese-synthese.ea")
|
||||||
'liste_contrat_atos.ea')
|
|
||||||
self.location('https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/releve/liste_comptes.jsp')
|
|
||||||
return self.page.get_accounts_list()
|
return self.page.get_accounts_list()
|
||||||
|
|
||||||
def get_account(self, id):
|
def get_account(self, id):
|
||||||
if not self.is_on_page(AccountList):
|
if not self.is_on_page(AccountList):
|
||||||
self.location('https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/authentification/'
|
self.location("https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/comptesCommun/synthese_assurancesEtComptes/afficheSynthese-synthese.ea")
|
||||||
'liste_contrat_atos.ea')
|
|
||||||
self.location('https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/releve/liste_comptes.jsp')
|
|
||||||
return self.page.get_account(id)
|
return self.page.get_account(id)
|
||||||
|
|
||||||
def get_history(self, Account):
|
def get_history(self, Account):
|
||||||
|
|
@ -86,8 +87,7 @@ class BPBrowser(BaseBrowser):
|
||||||
return self.page.get_history()
|
return self.page.get_history()
|
||||||
|
|
||||||
def make_transfer(self, from_account, to_account, amount):
|
def make_transfer(self, from_account, to_account, amount):
|
||||||
self.location('https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/virementsafran/aiguillage/'
|
self.location('https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/virement/virementSafran_aiguillage/init-saisieComptes.ea')
|
||||||
'saisieComptes.ea')
|
|
||||||
self.page.set_accouts(from_account, to_account)
|
self.page.set_accouts(from_account, to_account)
|
||||||
|
|
||||||
#TODO: Check
|
#TODO: Check
|
||||||
|
|
|
||||||
|
|
@ -16,12 +16,11 @@
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
from .login import LoginPage, LoggedPage, BadLoginPage, AccountDesactivate
|
from .login import LoginPage, Initident, CheckPassword,repositionnerCheminCourant, BadLoginPage, AccountDesactivate
|
||||||
from .cookie import CookiePage
|
|
||||||
from .accountlist import AccountList
|
from .accountlist import AccountList
|
||||||
from .accounthistory import AccountHistory
|
from .accounthistory import AccountHistory
|
||||||
from .transfer import TransferChooseAccounts, CompleteTransfer, TransferConfirm, TransferSummary
|
from .transfer import TransferChooseAccounts, CompleteTransfer, TransferConfirm, TransferSummary
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['LoginPage', 'LoggedPage', 'CookiePage', "AccountList", 'AccountHistory', 'BadLoginPage',
|
__all__ = ['LoginPage','Initident', 'CheckPassword', 'repositionnerCheminCourant', "AccountList", 'AccountHistory', 'BadLoginPage',
|
||||||
'AccountDesactivate', 'TransferChooseAccounts', 'CompleteTransfer', 'TransferConfirm', 'TransferSummary']
|
'AccountDesactivate', 'TransferChooseAccounts', 'CompleteTransfer', 'TransferConfirm', 'TransferSummary']
|
||||||
|
|
|
||||||
|
|
@ -37,10 +37,6 @@ def remove_extra_spaces(data):
|
||||||
|
|
||||||
|
|
||||||
class AccountHistory(BasePage):
|
class AccountHistory(BasePage):
|
||||||
def on_loaded(self):
|
|
||||||
if self.document.docinfo.doctype == '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" ' \
|
|
||||||
'"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">':
|
|
||||||
self.browser.follow_link(url_regex="releve", tag="a")
|
|
||||||
|
|
||||||
def get_history(self):
|
def get_history(self):
|
||||||
mvt_table = self.document.xpath("//table[@id='mouvements']", smart_strings=False)[0]
|
mvt_table = self.document.xpath("//table[@id='mouvements']", smart_strings=False)[0]
|
||||||
|
|
@ -50,14 +46,17 @@ class AccountHistory(BasePage):
|
||||||
|
|
||||||
for mvt in mvt_ligne:
|
for mvt in mvt_ligne:
|
||||||
operation = Operation(len(operations))
|
operation = Operation(len(operations))
|
||||||
operation.date = mvt.xpath("./td")[0].text
|
operation.date = mvt.xpath("./td/span")[0].text
|
||||||
tp = mvt.xpath("./td")[1]
|
tmp = mvt.xpath("./td/span")[1]
|
||||||
operation.label = remove_extra_spaces(remove_html_tags(self.browser.parser.tostring(tp)))
|
operation.label = remove_extra_spaces(remove_html_tags(self.browser.parser.tostring(tmp)))
|
||||||
|
|
||||||
r = re.compile(r'\d+')
|
r = re.compile(r'\d+')
|
||||||
tp = mvt.xpath("./td/span")
|
|
||||||
|
tmp = mvt.xpath("./td/span/strong")
|
||||||
|
if not tmp:
|
||||||
|
tmp = mvt.xpath("./td/span")
|
||||||
amount = None
|
amount = None
|
||||||
for t in tp:
|
for t in tmp:
|
||||||
if r.search(t.text):
|
if r.search(t.text):
|
||||||
amount = t.text
|
amount = t.text
|
||||||
amount = ''.join( amount.replace('.', '').replace(',', '.').split() )
|
amount = ''.join( amount.replace('.', '').replace(',', '.').split() )
|
||||||
|
|
|
||||||
|
|
@ -38,15 +38,16 @@ class AccountList(BasePage):
|
||||||
if len(tables) < 1:
|
if len(tables) < 1:
|
||||||
return
|
return
|
||||||
|
|
||||||
lines = tables[0].xpath("./tbody/tr")
|
lines = tables[0].xpath(".//tbody/tr")
|
||||||
|
|
||||||
for line in lines:
|
for line in lines:
|
||||||
account = Account()
|
account = Account()
|
||||||
tp = line.xpath("./td/a")[0]
|
tmp = line.xpath("./td//a")[0]
|
||||||
account.label = tp.text
|
account.label = tmp.text
|
||||||
account.link_id = tp.get("href")
|
account.link_id = tmp.get("href")
|
||||||
account.id = line.xpath("./td")[1].text
|
tmp = line.xpath("./td//strong")
|
||||||
account.balance = float(''.join(line.xpath("./td/span")[0].text.replace('.','').replace(',','.').split()))
|
account.id = tmp[0].text
|
||||||
|
account.balance = float(''.join(tmp[1].text.replace('.','').replace(',','.').split()))
|
||||||
self.account_list.append(account)
|
self.account_list.append(account)
|
||||||
|
|
||||||
def get_account(self, id):
|
def get_account(self, id):
|
||||||
|
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
# Copyright(C) 2010 Nicolas Duhamel
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, version 3 of the License.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program; if not, write to the Free Software
|
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
|
|
||||||
|
|
||||||
from weboob.tools.browser import BasePage
|
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['CookiePage']
|
|
||||||
|
|
||||||
|
|
||||||
class CookiePage(BasePage):
|
|
||||||
pass
|
|
||||||
|
|
@ -20,8 +20,7 @@ import hashlib
|
||||||
|
|
||||||
from weboob.tools.browser import BasePage
|
from weboob.tools.browser import BasePage
|
||||||
|
|
||||||
|
__all__ = ['LoginPage', 'BadLoginPage', 'AccountDesactivate', 'Initident', 'CheckPassword', 'repositionnerCheminCourant']
|
||||||
__all__ = ['LoginPage', 'LoggedPage', 'BadLoginPage', 'AccountDesactivate']
|
|
||||||
|
|
||||||
|
|
||||||
def md5(file):
|
def md5(file):
|
||||||
|
|
@ -40,10 +39,9 @@ class LoginPage(BasePage):
|
||||||
'596e6fbd54d5b111fe5df8a4948e80a4', '9cdc989a4310554e7f5484d0d27a86ce',
|
'596e6fbd54d5b111fe5df8a4948e80a4', '9cdc989a4310554e7f5484d0d27a86ce',
|
||||||
'0183943de6c0e331f3b9fc49c704ac6d', '291b9987225193ab1347301b241e2187',
|
'0183943de6c0e331f3b9fc49c704ac6d', '291b9987225193ab1347301b241e2187',
|
||||||
'163279f1a46082408613d12394e4042a', 'b0a9c740c4cada01eb691b4acda4daea',
|
'163279f1a46082408613d12394e4042a', 'b0a9c740c4cada01eb691b4acda4daea',
|
||||||
'3c4307ee92a1f3b571a3c542eafcb330', 'dbccecfa2206bfdb4ca891476404cc68',
|
'3c4307ee92a1f3b571a3c542eafcb330', 'dbccecfa2206bfdb4ca891476404cc68']
|
||||||
]
|
|
||||||
process = lambda i: md5(self.browser.retrieve(('https://voscomptesenligne.labanquepostale.fr/wsost/OstBrokerWeb'
|
process = lambda i: md5(self.browser.retrieve(('https://voscomptesenligne.labanquepostale.fr/wsost/OstBrokerWeb/loginform?imgid=%d&0.25122230781963073' % i))[0])
|
||||||
'/loginform?imgid=%d&0.25122230781963073' % i))[0])
|
|
||||||
keypad = [process(i) for i in range(10)]
|
keypad = [process(i) for i in range(10)]
|
||||||
correspondance = [keypad.index(i) for i in LOCAL_HASH]
|
correspondance = [keypad.index(i) for i in LOCAL_HASH]
|
||||||
newpassword = ''.join(str(correspondance[int(c)]) for c in pwd)
|
newpassword = ''.join(str(correspondance[int(c)]) for c in pwd)
|
||||||
|
|
@ -54,9 +52,17 @@ class LoginPage(BasePage):
|
||||||
self.browser['username'] = login
|
self.browser['username'] = login
|
||||||
self.browser.submit()
|
self.browser.submit()
|
||||||
|
|
||||||
|
class repositionnerCheminCourant(BasePage):
|
||||||
|
def on_loaded(self):
|
||||||
|
self.browser.open("https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/securite/authentification/initialiser-identif.ea")
|
||||||
|
|
||||||
class LoggedPage(BasePage):
|
class Initident(BasePage):
|
||||||
pass
|
def on_loaded(self):
|
||||||
|
self.browser.open("https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/securite/authentification/verifierMotDePasse-identif.ea")
|
||||||
|
|
||||||
|
class CheckPassword(BasePage):
|
||||||
|
def on_loaded(self):
|
||||||
|
self.browser.open("https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/comptesCommun/synthese_assurancesEtComptes/init-synthese.ea")
|
||||||
|
|
||||||
|
|
||||||
class BadLoginPage(BasePage):
|
class BadLoginPage(BasePage):
|
||||||
|
|
|
||||||
|
|
@ -36,20 +36,19 @@ class TransferChooseAccounts(BasePage):
|
||||||
|
|
||||||
class CompleteTransfer(BasePage):
|
class CompleteTransfer(BasePage):
|
||||||
def complete_transfer(self, amount):
|
def complete_transfer(self, amount):
|
||||||
self.browser.select_form(name="VirementNationalForm")
|
self.browser.select_form(name="virement_unitaire_saisie_saisie_virement_sepa")
|
||||||
self.browser["montant"] = str(amount)
|
self.browser["montant"] = str(amount)
|
||||||
self.browser.submit()
|
self.browser.submit()
|
||||||
|
|
||||||
|
|
||||||
class TransferConfirm(BasePage):
|
class TransferConfirm(BasePage):
|
||||||
def confirm(self):
|
def confirm(self):
|
||||||
self.browser.location('https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/virementsafran/'
|
self.browser.location('https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/virement/virementSafran_national/confirmerVirementNational-virementNational.ea')
|
||||||
'virementnational/4-virementNational.ea')
|
|
||||||
|
|
||||||
|
|
||||||
class TransferSummary(BasePage):
|
class TransferSummary(BasePage):
|
||||||
def get_transfer_id(self):
|
def get_transfer_id(self):
|
||||||
p = self.document.xpath("//form/div/p")[0]
|
p = self.document.xpath("//div[@id='main']/div/p")[0]
|
||||||
|
|
||||||
#HACK for deal with bad encoding ...
|
#HACK for deal with bad encoding ...
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue