diff --git a/weboob/backends/bp/browser.py b/weboob/backends/bp/browser.py index df326e23..26725439 100644 --- a/weboob/backends/bp/browser.py +++ b/weboob/backends/bp/browser.py @@ -20,7 +20,8 @@ from datetime import datetime 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 from weboob.capabilities.bank import Transfer @@ -33,19 +34,23 @@ class BPBrowser(BaseBrowser): DOMAIN = 'voscomptesenligne.labanquepostale.fr' PROTOCOL = 'https' ENCODING = None # refer to the HTML encoding - PAGES = {r'.*wsost/OstBrokerWeb/loginform.*': LoginPage, - r'.*voscomptes/canalXHTML/identif\.ea.*': LoggedPage, - r'.*voscomptes/canalXHTML/releve/syntheseAssurancesEtComptes\.ea': CookiePage, - r'.*voscomptes/canalXHTML/releve/liste_comptes\.jsp': AccountList, - r'.*canalXHTML/relevesCCP/.*': AccountHistory, - r'.*canalXHTML/relevesEpargnes/.*': AccountHistory, - r'.*ost/messages\.CVS\.html\?param=0x132120c8.*' : BadLoginPage, - r'.*ost/messages\.CVS\.html\?param=0x132120cb.*' : AccountDesactivate, + PAGES = {r'.*wsost/OstBrokerWeb/loginform.*' : LoginPage, + r'.*authentification/repositionnerCheminCourant-identif.ea' : repositionnerCheminCourant, + r'.*authentification/initialiser-identif.ea' : Initident, + r'.*authentification/verifierMotDePasse-identif.ea' : CheckPassword, + + r'.*synthese_assurancesEtComptes/afficheSynthese-synthese\.ea' : AccountList, + + r'.*CCP/releves_ccp/releveCPP-releve_ccp\.ea' : AccountHistory, + 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'.*/virementsafran/aiguillage/saisieComptes\.ea.*': TransferChooseAccounts, - r'.*/virementsafran/aiguillage/2-saisieComptes\.ea.*' : CompleteTransfer, - r'.*/virementsafran/virementnational/2-virementNational\.ea.*' : TransferConfirm, - r'.*/virementsafran/virementnational/4-virementNational\.ea.*' : TransferSummary, + r'.*ost/messages\.CVS\.html\?param=0x132120c8.*' : BadLoginPage, + r'.*ost/messages\.CVS\.html\?param=0x132120cb.*' : AccountDesactivate, } def home(self): @@ -69,16 +74,12 @@ class BPBrowser(BaseBrowser): raise BrowserBanned() def get_accounts_list(self): - self.location('https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/authentification/' - 'liste_contrat_atos.ea') - self.location('https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/releve/liste_comptes.jsp') + self.location("https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/comptesCommun/synthese_assurancesEtComptes/afficheSynthese-synthese.ea") return self.page.get_accounts_list() def get_account(self, id): if not self.is_on_page(AccountList): - self.location('https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/authentification/' - 'liste_contrat_atos.ea') - self.location('https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/releve/liste_comptes.jsp') + self.location("https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/comptesCommun/synthese_assurancesEtComptes/afficheSynthese-synthese.ea") return self.page.get_account(id) def get_history(self, Account): @@ -86,8 +87,7 @@ class BPBrowser(BaseBrowser): return self.page.get_history() def make_transfer(self, from_account, to_account, amount): - self.location('https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/virementsafran/aiguillage/' - 'saisieComptes.ea') + self.location('https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/virement/virementSafran_aiguillage/init-saisieComptes.ea') self.page.set_accouts(from_account, to_account) #TODO: Check diff --git a/weboob/backends/bp/pages/__init__.py b/weboob/backends/bp/pages/__init__.py index 0b10136b..fcde403a 100644 --- a/weboob/backends/bp/pages/__init__.py +++ b/weboob/backends/bp/pages/__init__.py @@ -16,12 +16,11 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -from .login import LoginPage, LoggedPage, BadLoginPage, AccountDesactivate -from .cookie import CookiePage +from .login import LoginPage, Initident, CheckPassword,repositionnerCheminCourant, BadLoginPage, AccountDesactivate from .accountlist import AccountList from .accounthistory import AccountHistory 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'] diff --git a/weboob/backends/bp/pages/accounthistory.py b/weboob/backends/bp/pages/accounthistory.py index 6c23f5f8..2e86081e 100644 --- a/weboob/backends/bp/pages/accounthistory.py +++ b/weboob/backends/bp/pages/accounthistory.py @@ -37,10 +37,6 @@ def remove_extra_spaces(data): class AccountHistory(BasePage): - def on_loaded(self): - if self.document.docinfo.doctype == '': - self.browser.follow_link(url_regex="releve", tag="a") def get_history(self): mvt_table = self.document.xpath("//table[@id='mouvements']", smart_strings=False)[0] @@ -50,14 +46,17 @@ class AccountHistory(BasePage): for mvt in mvt_ligne: operation = Operation(len(operations)) - operation.date = mvt.xpath("./td")[0].text - tp = mvt.xpath("./td")[1] - operation.label = remove_extra_spaces(remove_html_tags(self.browser.parser.tostring(tp))) + operation.date = mvt.xpath("./td/span")[0].text + tmp = mvt.xpath("./td/span")[1] + operation.label = remove_extra_spaces(remove_html_tags(self.browser.parser.tostring(tmp))) 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 - for t in tp: + for t in tmp: if r.search(t.text): amount = t.text amount = ''.join( amount.replace('.', '').replace(',', '.').split() ) diff --git a/weboob/backends/bp/pages/accountlist.py b/weboob/backends/bp/pages/accountlist.py index 02b97e07..8702e18a 100644 --- a/weboob/backends/bp/pages/accountlist.py +++ b/weboob/backends/bp/pages/accountlist.py @@ -38,15 +38,16 @@ class AccountList(BasePage): if len(tables) < 1: return - lines = tables[0].xpath("./tbody/tr") + lines = tables[0].xpath(".//tbody/tr") for line in lines: account = Account() - tp = line.xpath("./td/a")[0] - account.label = tp.text - account.link_id = tp.get("href") - account.id = line.xpath("./td")[1].text - account.balance = float(''.join(line.xpath("./td/span")[0].text.replace('.','').replace(',','.').split())) + tmp = line.xpath("./td//a")[0] + account.label = tmp.text + account.link_id = tmp.get("href") + tmp = line.xpath("./td//strong") + account.id = tmp[0].text + account.balance = float(''.join(tmp[1].text.replace('.','').replace(',','.').split())) self.account_list.append(account) def get_account(self, id): diff --git a/weboob/backends/bp/pages/cookie.py b/weboob/backends/bp/pages/cookie.py deleted file mode 100644 index a200daaa..00000000 --- a/weboob/backends/bp/pages/cookie.py +++ /dev/null @@ -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 diff --git a/weboob/backends/bp/pages/login.py b/weboob/backends/bp/pages/login.py index a38bc4a2..fa6cd7d1 100644 --- a/weboob/backends/bp/pages/login.py +++ b/weboob/backends/bp/pages/login.py @@ -20,8 +20,7 @@ import hashlib from weboob.tools.browser import BasePage - -__all__ = ['LoginPage', 'LoggedPage', 'BadLoginPage', 'AccountDesactivate'] +__all__ = ['LoginPage', 'BadLoginPage', 'AccountDesactivate', 'Initident', 'CheckPassword', 'repositionnerCheminCourant'] def md5(file): @@ -37,13 +36,12 @@ class LoginPage(BasePage): def login(self, login, pwd): LOCAL_HASH = ['a02574d7bf67677d2a86b7bfc5e864fe', 'eb85e1cc45dd6bdb3cab65c002d7ac8a', - '596e6fbd54d5b111fe5df8a4948e80a4', '9cdc989a4310554e7f5484d0d27a86ce', - '0183943de6c0e331f3b9fc49c704ac6d', '291b9987225193ab1347301b241e2187', - '163279f1a46082408613d12394e4042a', 'b0a9c740c4cada01eb691b4acda4daea', - '3c4307ee92a1f3b571a3c542eafcb330', 'dbccecfa2206bfdb4ca891476404cc68', - ] - process = lambda i: md5(self.browser.retrieve(('https://voscomptesenligne.labanquepostale.fr/wsost/OstBrokerWeb' - '/loginform?imgid=%d&0.25122230781963073' % i))[0]) + '596e6fbd54d5b111fe5df8a4948e80a4', '9cdc989a4310554e7f5484d0d27a86ce', + '0183943de6c0e331f3b9fc49c704ac6d', '291b9987225193ab1347301b241e2187', + '163279f1a46082408613d12394e4042a', 'b0a9c740c4cada01eb691b4acda4daea', + '3c4307ee92a1f3b571a3c542eafcb330', 'dbccecfa2206bfdb4ca891476404cc68'] + + process = lambda i: md5(self.browser.retrieve(('https://voscomptesenligne.labanquepostale.fr/wsost/OstBrokerWeb/loginform?imgid=%d&0.25122230781963073' % i))[0]) keypad = [process(i) for i in range(10)] correspondance = [keypad.index(i) for i in LOCAL_HASH] newpassword = ''.join(str(correspondance[int(c)]) for c in pwd) @@ -54,9 +52,17 @@ class LoginPage(BasePage): self.browser['username'] = login 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): - pass +class Initident(BasePage): + 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): diff --git a/weboob/backends/bp/pages/transfer.py b/weboob/backends/bp/pages/transfer.py index a1bffe1c..88518f4b 100644 --- a/weboob/backends/bp/pages/transfer.py +++ b/weboob/backends/bp/pages/transfer.py @@ -36,20 +36,19 @@ class TransferChooseAccounts(BasePage): class CompleteTransfer(BasePage): 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.submit() class TransferConfirm(BasePage): def confirm(self): - self.browser.location('https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/virementsafran/' - 'virementnational/4-virementNational.ea') + self.browser.location('https://voscomptesenligne.labanquepostale.fr/voscomptes/canalXHTML/virement/virementSafran_national/confirmerVirementNational-virementNational.ea') class TransferSummary(BasePage): 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 ... try: