diff --git a/modules/ing/browser.py b/modules/ing/browser.py index e5366bc6..0cc89d5c 100644 --- a/modules/ing/browser.py +++ b/modules/ing/browser.py @@ -34,7 +34,7 @@ class Ing(BaseBrowser): PROTOCOL = 'https' DEBUG_HTTP = False #DEBUG_HTTP = True - ENCODING = "utf-8" + ENCODING = None PAGES = {'.*pages/index.jsf.*': AccountsList, '.*displayLogin.jsf.*': LoginPage, '.*transferManagement.jsf': TransferPage, @@ -51,6 +51,7 @@ class Ing(BaseBrowser): transferpage = '/protected/pages/cc/transfer/transferManagement.jsf' dotransferpage = '/general?command=DisplayDoTransferCommand' valtransferpage = '/protected/pages/cc/transfer/create/transferCreateValidation.jsf' + billpage = '/protected/pages/common/estatement/eStatement.jsf' where = None def __init__(self, *args, **kwargs): @@ -189,8 +190,15 @@ class Ing(BaseBrowser): def get_bills(self, subscription): if not self.is_on_page(BillsPage): - self.location('/protected/pages/common/estatement/eStatement.jsf') - self.page.selectyear(subscription._localid) + self.location(self.billpage) + data = {"AJAXREQUEST": "_viewRoot", + "accountsel_form": "accountsel_form", + subscription._formid: subscription._formid, + "autoScroll": "", + "javax.faces.ViewState": subscription._javax, + "transfer_issuer_radio": subscription.id + } + self.location(self.billpage, urllib.urlencode(data)) while 1: for bill in self.page.iter_bills(subscription.id): yield bill diff --git a/modules/ing/pages/bills.py b/modules/ing/pages/bills.py index 7c75013b..f1782d2d 100644 --- a/modules/ing/pages/bills.py +++ b/modules/ing/pages/bills.py @@ -30,24 +30,24 @@ class BillsPage(BasePage): pass def iter_account(self): - ul = self.document.xpath('//ul[@id="accountsel_form:accountsel"]') + ul = self.document.xpath('//ul[@class="unstyled striped"]') + javax = self.document.xpath("//form[@id='accountsel_form']/input[@name='javax.faces.ViewState']") + javax = javax[0].attrib['value'] #subscriber = unicode(self.document.find('//h5').text) - for li in ul[0].xpath('li/a'): - label = li.text - id = label.split(' ')[-1] + for li in ul[0].xpath('li'): + inputs = li.xpath('input')[0] + label = li.xpath('label')[0] + label = unicode(label.text) + formid = inputs.attrib['onclick'] + formid = formid.split("parameters")[1] + formid = formid.split("'")[2] + id = inputs.attrib['value'] subscription = Subscription(id) subscription.label = label -# subscription.subscriber = subscriber - subscription._localid = li.attrib['id'] + subscription._formid = formid + subscription._javax = javax yield subscription - def selectyear(self, id): - self.browser.select_form("accountsel_form") - self.browser.set_all_readonly(False) - self.browser.controls.append(ClientForm.TextControl('text', 'AJAXREQUEST', {'value': 'accountsel_form:accountsel_region'})) - self.browser.controls.append(ClientForm.TextControl('text', id, {'value': id})) - self.browser.submit(nologin=True) - def postpredown(self, id): self.browser.select_form("statements_form") self.browser.set_all_readonly(False)