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 = True
ENCODING = None # refer to the HTML encoding
PAGES = {'.*displayTRAccountSummary.*': AccountsList,
PAGES = {'.*pages/index.jsf.*': AccountsList,
'.*displayLogin.jsf.*': LoginPage,
'.*accountDetail.jsf.*': AccountHistory,
'.*displayTRHistorique.*': AccountHistory,

View file

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