first page of history correctly parsed
This commit is contained in:
parent
a920de34ee
commit
1e9e4541cb
3 changed files with 29 additions and 29 deletions
|
|
@ -36,15 +36,14 @@ class CreditCooperatifBackend(BaseBackend, ICapBank):
|
|||
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),
|
||||
ValueBackendPassword('pin', label='One time pin'))
|
||||
|
||||
BROWSER = CreditCooperatif
|
||||
|
||||
def create_default_browser(self):
|
||||
print "One time PIN please: ",
|
||||
pin = raw_input()
|
||||
return self.create_browser(self.config['login'].get(),
|
||||
pin)
|
||||
self.config['pin'].get())
|
||||
|
||||
def iter_accounts(self):
|
||||
with self.browser:
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class CreditCooperatif(BaseBrowser):
|
|||
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
|
||||
'https://www.coopanet.com/banque/cpt/cpt/situationcomptes.do\?lnkReleveAction=X&numeroExterne=(.*)': TransactionsPage
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
|
@ -87,7 +87,6 @@ class CreditCooperatif(BaseBrowser):
|
|||
return None
|
||||
|
||||
def get_history(self, account):
|
||||
import pdb;pdb.set_trace()
|
||||
self.location('/banque/cpt/cpt/situationcomptes.do?lnkReleveAction=X&numeroExterne='+ account.id)
|
||||
|
||||
while 1:
|
||||
|
|
|
|||
|
|
@ -55,23 +55,22 @@ class AccountsPage(BasePage):
|
|||
return False
|
||||
|
||||
def get_list(self):
|
||||
for tbCompte in self.document.xpath('//table[@id="compte"]'):
|
||||
for trCompte in tbCompte.xpath('.//tbody/tr'):
|
||||
tds = trCompte.findall('td')
|
||||
|
||||
account = Account()
|
||||
for trCompte in self.document.xpath('//table[@id="compte"]/tbody/tr'):
|
||||
tds = trCompte.findall('td')
|
||||
|
||||
account = Account()
|
||||
|
||||
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[self.CPT_ROW_NATURE].xpath('.//td[@class="txt"]')]).strip()
|
||||
|
||||
account.type = self.ACCOUNT_TYPES.get(account_type_str, Account.TYPE_UNKNOWN)
|
||||
|
||||
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[self.CPT_ROW_NATURE].xpath('.//td[@class="txt"]')]).strip()
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
class Transaction(FrenchTransaction):
|
||||
|
|
@ -119,19 +118,22 @@ class TransactionsPage(BasePage):
|
|||
TRA_ROW_CREDIT = 5
|
||||
|
||||
def get_history(self):
|
||||
import pdb;pdb.set_trace()
|
||||
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()
|
||||
return ret.replace(u"\xa0", " ").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()])
|
||||
credit = u''.join([txt.strip() for txt in tds[-1].itertext()])
|
||||
date = get_content(tds[0])
|
||||
raw = get_content(tds[2])
|
||||
|
||||
debit = get_content(tds[3])
|
||||
credit = get_content(tds[4])
|
||||
|
||||
t = Transaction(date+""+raw)
|
||||
t.parse(date, re.sub(r'[ ]+', ' ', raw))
|
||||
t.set_amount(credit, debit)
|
||||
|
||||
yield t
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue