LIST working quite well
This commit is contained in:
parent
e6a837f6ab
commit
a920de34ee
3 changed files with 51 additions and 40 deletions
|
|
@ -31,18 +31,20 @@ __all__ = ['CreditCooperatifBackend']
|
||||||
|
|
||||||
class CreditCooperatifBackend(BaseBackend, ICapBank):
|
class CreditCooperatifBackend(BaseBackend, ICapBank):
|
||||||
NAME = 'creditcooperatif'
|
NAME = 'creditcooperatif'
|
||||||
MAINTAINER = u'Kevin Pouget'
|
MAINTAINER = u'Kevin Pouget 1459'
|
||||||
EMAIL = 'weboob@kevin.pouget.me'
|
EMAIL = 'weboob@kevin.pouget.me'
|
||||||
VERSION = '0.d'
|
VERSION = '0.d'
|
||||||
DESCRIPTION = u'Credit Cooperatif French bank website'
|
DESCRIPTION = u'Credit Cooperatif French bank website'
|
||||||
LICENSE = 'AGPLv3+'
|
LICENSE = 'AGPLv3+'
|
||||||
CONFIG = BackendConfig(ValueBackendPassword('login', label='Account ID', masked=False))
|
CONFIG = BackendConfig(ValueBackendPassword('login', label='Account ID', masked=False))
|
||||||
|
|
||||||
BROWSER = CreditCooperatif
|
BROWSER = CreditCooperatif
|
||||||
WEBSITE = "www.coopanet.com"
|
|
||||||
def create_default_browser(self):
|
def create_default_browser(self):
|
||||||
return self.create_browser(WEBSITE,
|
print "One time PIN please: ",
|
||||||
self.config['login'].get(),
|
pin = raw_input()
|
||||||
self.config['password'].get())
|
return self.create_browser(self.config['login'].get(),
|
||||||
|
pin)
|
||||||
|
|
||||||
def iter_accounts(self):
|
def iter_accounts(self):
|
||||||
with self.browser:
|
with self.browser:
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import urllib
|
||||||
|
|
||||||
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
|
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
|
||||||
|
|
||||||
from .pages import LoginPage, AccountsPage
|
from .pages import LoginPage, AccountsPage, TransactionsPage
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['CreditCooperatif']
|
__all__ = ['CreditCooperatif']
|
||||||
|
|
@ -31,15 +31,20 @@ __all__ = ['CreditCooperatif']
|
||||||
class CreditCooperatif(BaseBrowser):
|
class CreditCooperatif(BaseBrowser):
|
||||||
PROTOCOL = 'https'
|
PROTOCOL = 'https'
|
||||||
ENCODING = 'iso-8859-15'
|
ENCODING = 'iso-8859-15'
|
||||||
PAGES = {'https://[^/]+/banque/sso/ssologin.do".*': LoginPage,
|
DOMAIN = "www.coopanet.com"
|
||||||
'https://[^/]+/cyber/internet/StartTask.do\?taskInfoOID=mesComptes.*': AccountsPage
|
PAGES = {'https://www.coopanet.com/banque/sso/.*': LoginPage,
|
||||||
|
'https://www.coopanet.com/banque/cpt/incoopanetj2ee.do.*': AccountsPage,
|
||||||
|
'https://www.coopanet.com/banque/cpt/cpt/situationcomptes.do?lnkReleveAction=X&numeroExterne=.*': TransactionsPage # not recognized
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, website, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
self.DOMAIN = website
|
BaseBrowser.__init__(self, *args, **kwargs)
|
||||||
self.token = None
|
self.token = None
|
||||||
|
|
||||||
BaseBrowser.__init__(self, *args, **kwargs)
|
def home(self):
|
||||||
|
self.location("/banque/sso/")
|
||||||
|
|
||||||
|
assert self.is_on_page(LoginPage)
|
||||||
|
|
||||||
def is_logged(self):
|
def is_logged(self):
|
||||||
return not self.is_on_page(LoginPage)
|
return not self.is_on_page(LoginPage)
|
||||||
|
|
@ -49,6 +54,7 @@ class CreditCooperatif(BaseBrowser):
|
||||||
Attempt to log in.
|
Attempt to log in.
|
||||||
Note: this method does nothing if we are already logged in.
|
Note: this method does nothing if we are already logged in.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
assert isinstance(self.username, basestring)
|
assert isinstance(self.username, basestring)
|
||||||
assert isinstance(self.password, basestring)
|
assert isinstance(self.password, basestring)
|
||||||
|
|
||||||
|
|
@ -63,10 +69,8 @@ class CreditCooperatif(BaseBrowser):
|
||||||
if not self.is_logged():
|
if not self.is_logged():
|
||||||
raise BrowserIncorrectPassword()
|
raise BrowserIncorrectPassword()
|
||||||
|
|
||||||
self.token = self.page.get_token()
|
|
||||||
|
|
||||||
def get_accounts_list(self):
|
def get_accounts_list(self):
|
||||||
self.location(self.buildurl('/cyber/internet/StartTask.do', taskInfoOID='mesComptes', token=self.token))
|
self.location(self.buildurl('/banque/cpt/incoopanetj2ee.do?ssomode=ok'))
|
||||||
if self.page.is_error():
|
if self.page.is_error():
|
||||||
self.location(self.buildurl('/cyber/internet/StartTask.do', taskInfoOID='maSyntheseGratuite', token=self.token))
|
self.location(self.buildurl('/cyber/internet/StartTask.do', taskInfoOID='maSyntheseGratuite', token=self.token))
|
||||||
|
|
||||||
|
|
@ -83,7 +87,8 @@ class CreditCooperatif(BaseBrowser):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_history(self, account):
|
def get_history(self, account):
|
||||||
self.location('/cyber/internet/ContinueTask.do', urllib.urlencode(account._params))
|
import pdb;pdb.set_trace()
|
||||||
|
self.location('/banque/cpt/cpt/situationcomptes.do?lnkReleveAction=X&numeroExterne='+ account.id)
|
||||||
|
|
||||||
while 1:
|
while 1:
|
||||||
assert self.is_on_page(TransactionsPage)
|
assert self.is_on_page(TransactionsPage)
|
||||||
|
|
|
||||||
|
|
@ -29,17 +29,13 @@ from weboob.tools.capabilities.bank.transactions import FrenchTransaction
|
||||||
|
|
||||||
__all__ = ['LoginPage', 'AccountsPage']
|
__all__ = ['LoginPage', 'AccountsPage']
|
||||||
|
|
||||||
|
|
||||||
class UnavailablePage(BasePage):
|
|
||||||
def on_loaded(self):
|
|
||||||
a = self.document.xpath('//a[@class="btn"]')[0]
|
|
||||||
self.browser.location(a.attrib['href'])
|
|
||||||
|
|
||||||
class LoginPage(BasePage):
|
class LoginPage(BasePage):
|
||||||
def login(self, login, passwd):
|
def login(self, login, pin):
|
||||||
self.browser.select_form(name='loginCoForm')
|
self.browser.select_form(name='loginCoForm', nr=1)
|
||||||
self.browser['codeUtil'] = login
|
self.browser['codeUtil'] = login
|
||||||
self.browser['motPasse'] = passwd
|
self.browser['motPasse'] = pin
|
||||||
|
|
||||||
|
assert self.browser['identType'] == "RENFORCE"
|
||||||
self.browser.submit(nologin=True)
|
self.browser.submit(nologin=True)
|
||||||
|
|
||||||
class AccountsPage(BasePage):
|
class AccountsPage(BasePage):
|
||||||
|
|
@ -52,8 +48,8 @@ class AccountsPage(BasePage):
|
||||||
CPT_ROW_ENCOURS = 4
|
CPT_ROW_ENCOURS = 4
|
||||||
|
|
||||||
def is_error(self):
|
def is_error(self):
|
||||||
for script in self.document.xpath('//script'):
|
for par in self.document.xpath('//p[@class=acctxtnoirlien]'):
|
||||||
if script.text is not None and u"Le service est momentanément indisponible" in script.text:
|
if par.text is not None and u"La page demandée ne peut pas être affichée." in par.text:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
@ -61,21 +57,19 @@ class AccountsPage(BasePage):
|
||||||
def get_list(self):
|
def get_list(self):
|
||||||
for tbCompte in self.document.xpath('//table[@id="compte"]'):
|
for tbCompte in self.document.xpath('//table[@id="compte"]'):
|
||||||
for trCompte in tbCompte.xpath('.//tbody/tr'):
|
for trCompte in tbCompte.xpath('.//tbody/tr'):
|
||||||
tds = tr.findall('td')
|
tds = trCompte.findall('td')
|
||||||
|
|
||||||
account = Account()
|
account = Account()
|
||||||
|
|
||||||
account.id = tds[CPT_ROW_ID].text()
|
account.id = tds[self.CPT_ROW_ID].text.strip()
|
||||||
account.label = tds[CPT_ROW_NAME].text()
|
account.label = tds[self.CPT_ROW_NAME].text.strip()
|
||||||
|
|
||||||
account_type_str = "".join([td.text() for td in tds[CPT_ROW_ID].xpath('.//td[@id="tx"]')]).strip()
|
account_type_str = "".join([td.text for td in tds[self.CPT_ROW_NATURE].xpath('.//td[@class="txt"]')]).strip()
|
||||||
|
|
||||||
account.type = ACCOUNT_TYPES.get(account_type_str, Account.TYPE_UNKNOWN)
|
account.type = self.ACCOUNT_TYPES.get(account_type_str, Account.TYPE_UNKNOWN)
|
||||||
|
|
||||||
balance_link = tds[CPT_ROW_BALANCE].find("a")
|
|
||||||
|
|
||||||
account.balance = Decimal(FrenchTransaction.clean_amount(blance_link.text()))
|
|
||||||
|
|
||||||
|
account.balance = Decimal(FrenchTransaction.clean_amount(tds[self.CPT_ROW_BALANCE].find("a").text))
|
||||||
|
account.coming = Decimal(FrenchTransaction.clean_amount( tds[self.CPT_ROW_ENCOURS].find("a").text))
|
||||||
yield account
|
yield account
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
@ -118,12 +112,22 @@ class TransactionsPage(BasePage):
|
||||||
|
|
||||||
return params
|
return params
|
||||||
|
|
||||||
|
TRA_ROW_DT_OP = 0
|
||||||
|
TRA_ROW_DT_VAL = 1
|
||||||
|
TRA_ROW_NAME = 3
|
||||||
|
TRA_ROW_DEBIT = 4
|
||||||
|
TRA_ROW_CREDIT = 5
|
||||||
|
|
||||||
def get_history(self):
|
def get_history(self):
|
||||||
for tr in self.document.xpath('//table[@id="tbl1"]/tbody/tr'):
|
for tr in self.document.xpath('//table[@id="operation"]/tbody/tr'):
|
||||||
|
import pdb;pdb.set_trace()
|
||||||
tds = tr.findall('td')
|
tds = tr.findall('td')
|
||||||
|
|
||||||
t = Transaction(tr.attrib['id'].split('_', 1)[1])
|
def get_content(td):
|
||||||
|
ret = "".join([ttd.text for ttd in td.xpath(".//td")])
|
||||||
|
return ret.replace(" ", " ").strip()
|
||||||
|
|
||||||
|
t = Transaction(tr.attrib['id'].split('_', 1)[1])
|
||||||
date = u''.join([txt.strip() for txt in tds[4].itertext()])
|
date = u''.join([txt.strip() for txt in tds[4].itertext()])
|
||||||
raw = u' '.join([txt.strip() for txt in tds[1].itertext()])
|
raw = u' '.join([txt.strip() for txt in tds[1].itertext()])
|
||||||
debit = u''.join([txt.strip() for txt in tds[-2].itertext()])
|
debit = u''.join([txt.strip() for txt in tds[-2].itertext()])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue