Get accounts on the new website

This commit is contained in:
Florent 2013-02-22 09:36:39 +01:00 committed by Romain Bignon
commit c6e5f41983
2 changed files with 9 additions and 20 deletions

View file

@ -34,7 +34,7 @@ class Ing(BaseBrowser):
DEBUG_HTTP = False DEBUG_HTTP = False
#DEBUG_HTTP = True #DEBUG_HTTP = True
ENCODING = None # refer to the HTML encoding ENCODING = None # refer to the HTML encoding
PAGES = {'.*displayTRAccountSummary.*': AccountsList, PAGES = {'.*pages/index.jsf.*': AccountsList,
'.*displayLogin.jsf.*': LoginPage, '.*displayLogin.jsf.*': LoginPage,
'.*accountDetail.jsf.*': AccountHistory, '.*accountDetail.jsf.*': AccountHistory,
'.*displayTRHistorique.*': AccountHistory, '.*displayTRHistorique.*': AccountHistory,

View file

@ -35,24 +35,13 @@ class AccountsList(BasePage):
pass pass
def get_list(self): def get_list(self):
ids = set() # TODO: no idea abount how proxy account are displayed
for tr in self.document.xpath('//tr[@align="center"]'): for a in self.document.xpath('//a[@class="mainclic"]'):
error = tr.xpath('./td/font/b')
if len(error) > 0 and error[0].text == 'ERREUR':
raise BrowserUnavailable()
account = Account() account = Account()
account.currency = Currency.CUR_EUR account.currency = Currency.CUR_EUR
link = tr.xpath('.//a')[0] account.id = unicode(a.find('span[@class="account-number"]').text)
account._index = int(re.search('\d', link.attrib['href']).group(0)) account.label = unicode(a.find('span[@class="title"]').text)
if not account._index in ids: balance = a.find('span[@class="solde"]/label').text
ids.add(account._index) account.balance = Decimal(FrenchTransaction.clean_amount(balance))
account.id = unicode(link.text.strip()) account.coming = NotAvailable
account.label = account.id yield account
urltofind = './/a[@href="' + link.attrib['href'] + '"]'
linkbis = self.document.xpath(urltofind).pop()
if linkbis.text == link.text:
linkbis = self.document.xpath(urltofind)[1]
account.balance = Decimal(FrenchTransaction.clean_amount(linkbis.text))
account.coming = NotAvailable
yield account