use uniq IDs for accounts
This commit is contained in:
parent
9e41cd9483
commit
011dcc9688
3 changed files with 25 additions and 22 deletions
|
|
@ -50,8 +50,6 @@ class CreditMutuelBackend(BaseBackend, ICapBank):
|
||||||
yield account
|
yield account
|
||||||
|
|
||||||
def get_account(self, _id):
|
def get_account(self, _id):
|
||||||
if not _id.isdigit():
|
|
||||||
raise AccountNotFound()
|
|
||||||
account = self.browser.get_account(_id)
|
account = self.browser.get_account(_id)
|
||||||
if account:
|
if account:
|
||||||
return account
|
return account
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,8 @@ from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
|
||||||
from weboob.capabilities.bank import Transfer, TransferError
|
from weboob.capabilities.bank import Transfer, TransferError
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from .pages import LoginPage, LoginErrorPage, AccountsPage, UserSpacePage, OperationsPage, InfoPage, TransfertPage
|
from .pages import LoginPage, LoginErrorPage, AccountsPage, UserSpacePage, \
|
||||||
|
OperationsPage, NoOperationsPage, InfoPage, TransfertPage
|
||||||
|
|
||||||
__all__ = ['CreditMutuelBrowser']
|
__all__ = ['CreditMutuelBrowser']
|
||||||
|
|
||||||
|
|
@ -34,12 +35,13 @@ class CreditMutuelBrowser(BaseBrowser):
|
||||||
ENCODING = 'iso-8859-1'
|
ENCODING = 'iso-8859-1'
|
||||||
USER_AGENT = BaseBrowser.USER_AGENTS['wget']
|
USER_AGENT = BaseBrowser.USER_AGENTS['wget']
|
||||||
PAGES = {'https://www.creditmutuel.fr/groupe/fr/index.html': LoginPage,
|
PAGES = {'https://www.creditmutuel.fr/groupe/fr/index.html': LoginPage,
|
||||||
'https://www.creditmutuel.fr/groupe/fr/identification/default.cgi': LoginErrorPage,
|
'https://www.creditmutuel.fr/.*/fr/identification/default.cgi': LoginErrorPage,
|
||||||
'https://www.creditmutuel.fr/.*/fr/banque/situation_financiere.cgi': AccountsPage,
|
'https://www.creditmutuel.fr/.*/fr/banque/situation_financiere.cgi': AccountsPage,
|
||||||
'https://www.creditmutuel.fr/.*/fr/banque/espace_personnel.aspx': UserSpacePage,
|
'https://www.creditmutuel.fr/.*/fr/banque/espace_personnel.aspx': UserSpacePage,
|
||||||
'https://www.creditmutuel.fr/.*/fr/banque/mouvements.cgi.*': OperationsPage,
|
'https://www.creditmutuel.fr/.*/fr/banque/mouvements.cgi.*': OperationsPage,
|
||||||
'https://www.creditmutuel.fr/.*/fr/banque/nr/nr_devbooster.aspx.*': OperationsPage,
|
'https://www.creditmutuel.fr/.*/fr/banque/nr/nr_devbooster.aspx.*': OperationsPage,
|
||||||
'https://www.creditmutuel.fr/.*/fr/banque/operations_carte\.cgi.*': OperationsPage,
|
'https://www.creditmutuel.fr/.*/fr/banque/operations_carte\.cgi.*': OperationsPage,
|
||||||
|
'https://www.creditmutuel.fr/.*/fr/banque/arrivees\.asp.*': NoOperationsPage,
|
||||||
'https://www.creditmutuel.fr/.*/fr/banque/BAD.*': InfoPage,
|
'https://www.creditmutuel.fr/.*/fr/banque/BAD.*': InfoPage,
|
||||||
'https://www.creditmutuel.fr/.*/fr/banque/.*Vir.*': TransfertPage
|
'https://www.creditmutuel.fr/.*/fr/banque/.*Vir.*': TransfertPage
|
||||||
}
|
}
|
||||||
|
|
@ -50,7 +52,7 @@ class CreditMutuelBrowser(BaseBrowser):
|
||||||
#self.currentSubBank = None
|
#self.currentSubBank = None
|
||||||
|
|
||||||
def is_logged(self):
|
def is_logged(self):
|
||||||
return self.page and not self.is_on_page(LoginPage)
|
return self.page and not self.is_on_page(LoginPage) and not self.is_on_page(LoginErrorPage)
|
||||||
|
|
||||||
def home(self):
|
def home(self):
|
||||||
return self.location('https://www.creditmutuel.fr/groupe/fr/index.html')
|
return self.location('https://www.creditmutuel.fr/groupe/fr/index.html')
|
||||||
|
|
@ -102,16 +104,9 @@ class CreditMutuelBrowser(BaseBrowser):
|
||||||
self.location(page_url)
|
self.location(page_url)
|
||||||
else:
|
else:
|
||||||
self.location('https://%s/%s/fr/banque/%s' % (self.DOMAIN, self.currentSubBank, page_url))
|
self.location('https://%s/%s/fr/banque/%s' % (self.DOMAIN, self.currentSubBank, page_url))
|
||||||
#for page_operation in self.page.get_history(operations_count):
|
|
||||||
# operations_count += 1
|
|
||||||
# yield page_operation
|
|
||||||
|
|
||||||
## FONCTIONNE
|
if not self.is_on_page(OperationsPage):
|
||||||
#for op in self.page.get_history():
|
break
|
||||||
# yield op
|
|
||||||
|
|
||||||
## FONTIONNE
|
|
||||||
#return self.page.get_history()
|
|
||||||
|
|
||||||
for op in self.page.get_history():
|
for op in self.page.get_history():
|
||||||
l_ret.append(op)
|
l_ret.append(op)
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
from urlparse import urlparse, parse_qs
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
@ -30,7 +31,7 @@ class LoginPage(BasePage):
|
||||||
self.browser.select_form(nr=0)
|
self.browser.select_form(nr=0)
|
||||||
self.browser['_cm_user'] = login
|
self.browser['_cm_user'] = login
|
||||||
self.browser['_cm_pwd'] = passwd
|
self.browser['_cm_pwd'] = passwd
|
||||||
self.browser.submit()
|
self.browser.submit(nologin=True)
|
||||||
|
|
||||||
class LoginErrorPage(BasePage):
|
class LoginErrorPage(BasePage):
|
||||||
pass
|
pass
|
||||||
|
|
@ -46,23 +47,30 @@ class UserSpacePage(BasePage):
|
||||||
|
|
||||||
class AccountsPage(BasePage):
|
class AccountsPage(BasePage):
|
||||||
def get_list(self):
|
def get_list(self):
|
||||||
l = []
|
ids = set()
|
||||||
|
|
||||||
for tr in self.document.getiterator('tr'):
|
for tr in self.document.getiterator('tr'):
|
||||||
first_td = tr.getchildren()[0]
|
first_td = tr.getchildren()[0]
|
||||||
if (first_td.attrib.get('class', '') == 'i g' or first_td.attrib.get('class', '') == 'p g') \
|
if (first_td.attrib.get('class', '') == 'i g' or first_td.attrib.get('class', '') == 'p g') \
|
||||||
and first_td.find('a') is not None:
|
and first_td.find('a') is not None:
|
||||||
account = Account()
|
account = Account()
|
||||||
account.label = u"%s"%first_td.find('a').text.strip().lstrip(' 0123456789')
|
account.label = u"%s"%first_td.find('a').text.strip().lstrip(' 0123456789').capitalize()
|
||||||
account._link_id = first_td.find('a').get('href', '')
|
account._link_id = first_td.find('a').get('href', '')
|
||||||
if account._link_id.startswith('POR_SyntheseLst'):
|
if account._link_id.startswith('POR_SyntheseLst'):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
account.id = first_td.find('a').text.split(' ')[0]+first_td.find('a').text.split(' ')[1]
|
url = urlparse(account._link_id)
|
||||||
|
p = parse_qs(account._link_id)
|
||||||
if not account.id.isdigit():
|
if not 'rib' in p:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
account.id = p['rib'][0]
|
||||||
|
|
||||||
|
if account.id in ids:
|
||||||
|
continue
|
||||||
|
|
||||||
|
ids.add(account.id)
|
||||||
|
|
||||||
s = tr.getchildren()[2].text
|
s = tr.getchildren()[2].text
|
||||||
if s.strip() == "":
|
if s.strip() == "":
|
||||||
s = tr.getchildren()[1].text
|
s = tr.getchildren()[1].text
|
||||||
|
|
@ -73,9 +81,7 @@ class AccountsPage(BasePage):
|
||||||
if c == ',':
|
if c == ',':
|
||||||
balance += '.'
|
balance += '.'
|
||||||
account.balance = Decimal(balance)
|
account.balance = Decimal(balance)
|
||||||
l.append(account)
|
yield account
|
||||||
#raise NotImplementedError()
|
|
||||||
return l
|
|
||||||
|
|
||||||
def next_page_url(self):
|
def next_page_url(self):
|
||||||
""" TODO pouvoir passer à la page des comptes suivante """
|
""" TODO pouvoir passer à la page des comptes suivante """
|
||||||
|
|
@ -149,3 +155,7 @@ class OperationsPage(BasePage):
|
||||||
def next_page_url(self):
|
def next_page_url(self):
|
||||||
""" TODO pouvoir passer à la page des opérations suivantes """
|
""" TODO pouvoir passer à la page des opérations suivantes """
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
class NoOperationsPage(OperationsPage):
|
||||||
|
def get_history(self):
|
||||||
|
return iter([])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue