Support all the history

Ugly code...
This commit is contained in:
Florent 2013-02-22 17:58:50 +01:00 committed by Romain Bignon
commit 3d532ef501
2 changed files with 29 additions and 7 deletions

View file

@ -121,19 +121,26 @@ class Ing(BaseBrowser):
}
self.location(self.accountspage, urllib.urlencode(data))
self.where = "history"
jid = self.page.get_history_jid()
i = 0 # index, we get always the same page, but with more informations
while 1:
hashlist = []
for transaction in self.page.get_transactions():
for transaction in self.page.get_transactions(i):
while transaction.id in hashlist:
transaction.id = hashlib.md5(transaction.id + "1").hexdigest()
hashlist.append(transaction.id)
i += 1
yield transaction
if self.page.islast():
return
# XXX server sends an unknown mimetype, we overload
# viewing_html() above to prevent this issue.
self.page.next_page()
data = {"AJAX:EVENTS_COUNT": 1,
"AJAXREQUEST": "_viewRoot",
"autoScroll": "",
"index": "index",
"index:%s:moreTransactions" % jid: "index:%s:moreTransactions" % jid,
"javax.faces.ViewState": account._jid
}
self.location(self.accountspage, urllib.urlencode(data))
def get_recipients(self, account):
if not self.is_on_page(TransferPage):
@ -184,6 +191,7 @@ class Ing(BaseBrowser):
yield bill
if self.page.islast():
return
self.page.next_page()
def predownload(self, bill):

View file

@ -72,12 +72,17 @@ class AccountsList(BasePage):
account._jid = jid.attrib['value']
yield account
def get_transactions(self):
def get_transactions(self, index):
i = 0
for table in self.document.xpath('//table[@cellpadding="0"]'):
try:
textdate = table.find('.//td[@class="elmt tdate"]').text_content()
except AttributeError:
continue
# Do not parse transactions already parsed
if i < index:
i += 1
continue
if textdate == 'hier':
textdate = (date.today() - timedelta(days=1)).strftime('%d/%m/%Y')
elif textdate == "aujourd'hui":
@ -102,5 +107,14 @@ class AccountsList(BasePage):
op.amount = Decimal(amount)
yield op
def get_history_jid(self):
span = self.document.xpath('//span[starts-with(@id, "index:j_id")]')[0]
jid = span.attrib['id'].split(':')[1]
return jid
def islast(self):
return True
nomore = self.document.xpath('//span[@class="no-more-transactions"]')
if len(nomore) > 0:
return True
else:
return False