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):
|
||||
NAME = 'creditcooperatif'
|
||||
MAINTAINER = u'Kevin Pouget'
|
||||
MAINTAINER = u'Kevin Pouget 1459'
|
||||
EMAIL = 'weboob@kevin.pouget.me'
|
||||
VERSION = '0.d'
|
||||
DESCRIPTION = u'Credit Cooperatif French bank website'
|
||||
LICENSE = 'AGPLv3+'
|
||||
CONFIG = BackendConfig(ValueBackendPassword('login', label='Account ID', masked=False))
|
||||
CONFIG = BackendConfig(ValueBackendPassword('login', label='Account ID', masked=False))
|
||||
|
||||
BROWSER = CreditCooperatif
|
||||
WEBSITE = "www.coopanet.com"
|
||||
|
||||
def create_default_browser(self):
|
||||
return self.create_browser(WEBSITE,
|
||||
self.config['login'].get(),
|
||||
self.config['password'].get())
|
||||
print "One time PIN please: ",
|
||||
pin = raw_input()
|
||||
return self.create_browser(self.config['login'].get(),
|
||||
pin)
|
||||
|
||||
def iter_accounts(self):
|
||||
with self.browser:
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import urllib
|
|||
|
||||
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
|
||||
|
||||
from .pages import LoginPage, AccountsPage
|
||||
from .pages import LoginPage, AccountsPage, TransactionsPage
|
||||
|
||||
|
||||
__all__ = ['CreditCooperatif']
|
||||
|
|
@ -31,16 +31,21 @@ __all__ = ['CreditCooperatif']
|
|||
class CreditCooperatif(BaseBrowser):
|
||||
PROTOCOL = 'https'
|
||||
ENCODING = 'iso-8859-15'
|
||||
PAGES = {'https://[^/]+/banque/sso/ssologin.do".*': LoginPage,
|
||||
'https://[^/]+/cyber/internet/StartTask.do\?taskInfoOID=mesComptes.*': AccountsPage
|
||||
}
|
||||
DOMAIN = "www.coopanet.com"
|
||||
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):
|
||||
self.DOMAIN = website
|
||||
def __init__(self, *args, **kwargs):
|
||||
BaseBrowser.__init__(self, *args, **kwargs)
|
||||
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):
|
||||
return not self.is_on_page(LoginPage)
|
||||
|
||||
|
|
@ -49,6 +54,7 @@ class CreditCooperatif(BaseBrowser):
|
|||
Attempt to log in.
|
||||
Note: this method does nothing if we are already logged in.
|
||||
"""
|
||||
|
||||
assert isinstance(self.username, basestring)
|
||||
assert isinstance(self.password, basestring)
|
||||
|
||||
|
|
@ -63,10 +69,8 @@ class CreditCooperatif(BaseBrowser):
|
|||
if not self.is_logged():
|
||||
raise BrowserIncorrectPassword()
|
||||
|
||||
self.token = self.page.get_token()
|
||||
|
||||
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():
|
||||
self.location(self.buildurl('/cyber/internet/StartTask.do', taskInfoOID='maSyntheseGratuite', token=self.token))
|
||||
|
||||
|
|
@ -83,7 +87,8 @@ class CreditCooperatif(BaseBrowser):
|
|||
return None
|
||||
|
||||
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:
|
||||
assert self.is_on_page(TransactionsPage)
|
||||
|
|
|
|||
|
|
@ -29,21 +29,17 @@ from weboob.tools.capabilities.bank.transactions import FrenchTransaction
|
|||
|
||||
__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):
|
||||
def login(self, login, passwd):
|
||||
self.browser.select_form(name='loginCoForm')
|
||||
def login(self, login, pin):
|
||||
self.browser.select_form(name='loginCoForm', nr=1)
|
||||
self.browser['codeUtil'] = login
|
||||
self.browser['motPasse'] = passwd
|
||||
self.browser['motPasse'] = pin
|
||||
|
||||
assert self.browser['identType'] == "RENFORCE"
|
||||
self.browser.submit(nologin=True)
|
||||
|
||||
class AccountsPage(BasePage):
|
||||
ACCOUNT_TYPES = {u'COMPTE NEF': Account.TYPE_CHECKING
|
||||
ACCOUNT_TYPES = {u'COMPTE NEF': Account.TYPE_CHECKING
|
||||
}
|
||||
CPT_ROW_ID = 0
|
||||
CPT_ROW_NAME = 1
|
||||
|
|
@ -52,8 +48,8 @@ class AccountsPage(BasePage):
|
|||
CPT_ROW_ENCOURS = 4
|
||||
|
||||
def is_error(self):
|
||||
for script in self.document.xpath('//script'):
|
||||
if script.text is not None and u"Le service est momentanément indisponible" in script.text:
|
||||
for par in self.document.xpath('//p[@class=acctxtnoirlien]'):
|
||||
if par.text is not None and u"La page demandée ne peut pas être affichée." in par.text:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
|
@ -61,21 +57,19 @@ class AccountsPage(BasePage):
|
|||
def get_list(self):
|
||||
for tbCompte in self.document.xpath('//table[@id="compte"]'):
|
||||
for trCompte in tbCompte.xpath('.//tbody/tr'):
|
||||
tds = tr.findall('td')
|
||||
tds = trCompte.findall('td')
|
||||
|
||||
account = Account()
|
||||
|
||||
account.id = tds[CPT_ROW_ID].text()
|
||||
account.label = tds[CPT_ROW_NAME].text()
|
||||
account.id = tds[self.CPT_ROW_ID].text.strip()
|
||||
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)
|
||||
|
||||
balance_link = tds[CPT_ROW_BALANCE].find("a")
|
||||
|
||||
account.balance = Decimal(FrenchTransaction.clean_amount(blance_link.text()))
|
||||
account.type = self.ACCOUNT_TYPES.get(account_type_str, Account.TYPE_UNKNOWN)
|
||||
|
||||
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
|
||||
|
||||
return
|
||||
|
|
@ -118,12 +112,22 @@ class TransactionsPage(BasePage):
|
|||
|
||||
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):
|
||||
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')
|
||||
|
||||
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()])
|
||||
raw = u' '.join([txt.strip() for txt in tds[1].itertext()])
|
||||
debit = u''.join([txt.strip() for txt in tds[-2].itertext()])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue