new bnporc backend
This commit is contained in:
parent
655bc10e3e
commit
69bb9e4826
8 changed files with 498 additions and 0 deletions
26
weboob/backends/bnporc/pages/__init__.py
Normal file
26
weboob/backends/bnporc/pages/__init__.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Copyright(C) 2009-2010 Romain Bignon
|
||||
|
||||
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 .accounts_list import AccountsList
|
||||
from .account_coming import AccountComing
|
||||
from .login import LoginPage, ConfirmPage
|
||||
|
||||
class AccountHistory(AccountsList): pass
|
||||
class AccountPrelevement(AccountsList): pass
|
||||
51
weboob/backends/bnporc/pages/account_coming.py
Normal file
51
weboob/backends/bnporc/pages/account_coming.py
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Copyright(C) 2009-2010 Romain Bignon
|
||||
|
||||
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
|
||||
from weboob.capabilities.bank import Operation
|
||||
|
||||
class AccountComing(BasePage):
|
||||
|
||||
def loaded(self):
|
||||
self.operations = []
|
||||
|
||||
for tr in self.document.getiterator('tr'):
|
||||
if tr.attrib.get('class', '') == 'hdoc1' or tr.attrib.get('class', '') == 'hdotc1':
|
||||
operation = Operation()
|
||||
tds = tr.findall('td')
|
||||
if len(tds) != 3:
|
||||
continue
|
||||
date = tds[0].getchildren()[0].attrib.get('name', '')
|
||||
label = u''
|
||||
label += tds[1].text
|
||||
for child in tds[1].getchildren():
|
||||
if child.text: label += child.text
|
||||
if child.tail: label += child.tail
|
||||
label += tds[1].tail
|
||||
label = label.strip()
|
||||
amount = tds[2].text.replace('.','').replace(',','.')
|
||||
|
||||
operation.setDate(date)
|
||||
operation.setLabel(label)
|
||||
operation.setAmount(float(amount))
|
||||
self.operations.append(operation)
|
||||
|
||||
def get_operations(self):
|
||||
return self.operations
|
||||
61
weboob/backends/bnporc/pages/accounts_list.py
Normal file
61
weboob/backends/bnporc/pages/accounts_list.py
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Copyright(C) 2009-2010 Romain Bignon
|
||||
|
||||
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.
|
||||
|
||||
"""
|
||||
|
||||
import re
|
||||
|
||||
from weboob.capabilities.bank import Account
|
||||
from weboob.tools.browser import BasePage
|
||||
from weboob.tools.parser import tostring
|
||||
|
||||
class AccountsList(BasePage):
|
||||
LINKID_REGEXP = re.compile(".*ch4=(\w+).*")
|
||||
|
||||
def loaded(self):
|
||||
pass
|
||||
|
||||
def get_list(self):
|
||||
l = []
|
||||
for tr in self.document.getiterator('tr'):
|
||||
if tr.attrib.get('class', '') == 'comptes':
|
||||
account = Account()
|
||||
for td in tr.getiterator('td'):
|
||||
if td.attrib.get('headers', '').startswith('Numero_'):
|
||||
id = td.text
|
||||
account.setID(long(''.join(id.split(' '))))
|
||||
elif td.attrib.get('headers', '').startswith('Libelle_'):
|
||||
a = td.findall('a')
|
||||
label = unicode(a[0].text)
|
||||
account.setLabel(label)
|
||||
m = self.LINKID_REGEXP.match(a[0].attrib.get('href', ''))
|
||||
if m:
|
||||
account.setLinkID(m.group(1))
|
||||
elif td.attrib.get('headers', '').startswith('Solde'):
|
||||
a = td.findall('a')
|
||||
balance = a[0].text
|
||||
balance = balance.replace('.','').replace(',','.')
|
||||
account.setBalance(float(balance))
|
||||
elif td.attrib.get('headers', '').startswith('Avenir'):
|
||||
a = td.findall('a')
|
||||
coming = a[0].text
|
||||
coming = coming.replace('.','').replace(',','.')
|
||||
account.setComing(float(coming))
|
||||
|
||||
l.append(account)
|
||||
return l
|
||||
52
weboob/backends/bnporc/pages/login.py
Normal file
52
weboob/backends/bnporc/pages/login.py
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Copyright(C) 2009-2010 Romain Bignon
|
||||
|
||||
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.
|
||||
|
||||
"""
|
||||
|
||||
import ClientForm
|
||||
import sys
|
||||
|
||||
from weboob.tools.browser import BasePage
|
||||
from weboob.backends.bnporc.captcha import Captcha, TileError
|
||||
|
||||
class LoginPage(BasePage):
|
||||
def loaded(self):
|
||||
pass
|
||||
|
||||
def login(self, login, password):
|
||||
img = Captcha(self.browser.openurl('/NSImgGrille'))
|
||||
self.browser.back()
|
||||
|
||||
try:
|
||||
img.build_tiles()
|
||||
except TileError, err:
|
||||
print >>sys.stderr, "Error: %s" % err
|
||||
if err.tile:
|
||||
err.tile.display()
|
||||
|
||||
self.browser.select_form('logincanalnet')
|
||||
# HACK because of fucking malformed HTML, the field isn't recognized by mechanize.
|
||||
self.browser.controls.append(ClientForm.TextControl('text', 'ch1', {'value': ''}))
|
||||
self.browser.set_all_readonly(False)
|
||||
|
||||
self.browser['ch1'] = login
|
||||
self.browser['ch5'] = img.get_codes(password)
|
||||
self.browser.submit()
|
||||
|
||||
class ConfirmPage(BasePage):
|
||||
pass
|
||||
Loading…
Add table
Add a link
Reference in a new issue