sgpe: Working account list

This commit is contained in:
Laurent Bachelier 2013-07-22 12:51:11 +02:00
commit 4522b24a1a
2 changed files with 26 additions and 7 deletions

View file

@ -29,11 +29,11 @@ __all__ = ['SGProfessionalBrowser', 'SGEnterpriseBrowser']
class SGPEBrowser(BaseBrowser):
PROTOCOL = 'https'
ENCODING = None
ENCODING = 'ISO-8859-1'
def __init__(self, *args, **kwargs):
self.PAGES = OrderedDict((
('%s://%s/Pgn/.+PageID=Compte&.+' % (self.PROTOCOL, self.DOMAIN), AccountsPage),
('%s://%s/Pgn/.+PageID=SoldeV3&.+' % (self.PROTOCOL, self.DOMAIN), AccountsPage),
('%s://%s/' % (self.PROTOCOL, self.DOMAIN), LoginPage),
))
BaseBrowser.__init__(self, *args, **kwargs)
@ -65,12 +65,13 @@ class SGPEBrowser(BaseBrowser):
raise BrowserIncorrectPassword()
def accounts(self):
self.location('/Pgn/NavigationServlet?MenuID=%s&PageID=Compte&Classeur=1&NumeroPage=1&Origine=Menu' % self.MENUID)
self.location('/Pgn/NavigationServlet?PageID=SoldeV3&MenuID=%s&Classeur=1&NumeroPage=1' % self.MENUID)
def get_accounts_list(self):
if not self.is_on_page(AccountsPage):
self.accounts()
assert self.is_on_page(AccountsPage)
return self.page.get_list()
class SGProfessionalBrowser(SGPEBrowser):

View file

@ -19,11 +19,15 @@
from logging import error
import re
from weboob.tools.json import json
from weboob.tools.mech import ClientForm
from decimal import Decimal
from weboob.tools.browser import BasePage
from weboob.tools.json import json
from weboob.tools.mech import ClientForm
from weboob.tools.misc import to_unicode
from weboob.capabilities.bank import Account
from weboob.tools.capabilities.bank.transactions import FrenchTransaction
from ..captcha import Captcha, TileError
@ -81,4 +85,18 @@ class LoginPage(SGPEPage):
class AccountsPage(SGPEPage):
pass
def get_list(self):
table = self.parser.select(self.document.getroot(), '#tab-corps', 1)
for tr in self.parser.select(table, 'tr', 'many'):
tdname, tdid, tdagency, tdbalance = [td.text_content().strip()
for td
in self.parser.select(tr, 'td', 4)]
# it has empty rows - ignore those without the necessary info
if all((tdname, tdid, tdbalance)):
account = Account()
account.label = to_unicode(tdname)
account.id = to_unicode(tdid.replace(u'\xa0', '').replace(' ', ''))
account._agency = to_unicode(tdagency)
account.balance = Decimal(FrenchTransaction.clean_amount(tdbalance))
account.currency = account.get_currency(tdbalance)
yield account