diff --git a/modules/ing/browser.py b/modules/ing/browser.py index 6dd8d7fc..82986394 100644 --- a/modules/ing/browser.py +++ b/modules/ing/browser.py @@ -19,6 +19,7 @@ import hashlib from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword +from weboob.capabilities.bank import Account from .pages import AccountsList, LoginPage, LoginPage2, \ AccountHistory, TransferPage @@ -90,8 +91,9 @@ class Ing(BaseBrowser): # are always on a HTML document. return True - def get_history(self, id): - account = self.get_account(id) + def get_history(self, account): + if not isinstance(account, Account): + account = self.get_account(account) # The first and the second letter of the label are the account type if account.label[0:2] == "CC": self.location('https://secure.ingdirect.fr/protected/pages/cc/accountDetail.jsf') @@ -118,4 +120,10 @@ class Ing(BaseBrowser): def get_recipients(self, account): if not self.is_on_page(TransferPage): self.location('https://secure.ingdirect.fr/protected/pages/cc/transfer/transferManagement.jsf') - return self.page.get_recipients() + if self.page.ischecked(account): + return self.page.get_recipients() + else: + # It is hard to check the box and to get the real list. We try an alternative way like normal users + self.get_history(account.id).next() + self.location('https://secure.ingdirect.fr/general?command=DisplayDoTransferCommand') + return self.page.get_recipients() diff --git a/modules/ing/pages/transfer.py b/modules/ing/pages/transfer.py new file mode 100644 index 00000000..c1011c39 --- /dev/null +++ b/modules/ing/pages/transfer.py @@ -0,0 +1,71 @@ +# -*- coding: utf-8 -*- + +# Copyright(C) 2009-2011 Romain Bignon, Florent Fourcot +# +# This file is part of weboob. +# +# weboob is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# weboob is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with weboob. If not, see . + + +from weboob.capabilities.bank import Recipient, AccountNotFound +from weboob.tools.browser import BasePage + + +__all__ = ['TransferPage'] + + +class TransferPage(BasePage): + def on_loaded(self): + pass + + def get_recipients(self): + # First, internals recipients + table = self.document.xpath('//table[@id="transfer_form:receiptAccount"]') + for tr in table[0].xpath('tbody/tr'): + tds = tr.xpath('td') + id = tds[0].xpath('input')[0].attrib['value'] + name = tds[0].xpath('label')[0].text + name += u" " + tds[1].xpath('span')[0].text + recipient = Recipient() + recipient.id = id + recipient.label = name + yield recipient + + # Second, externals recipients + select = self.document.xpath('//select[@id="transfer_form:externalAccounts"]') + recipients = select[0].xpath('option') + recipients.pop(0) + for option in recipients: + recipient = Recipient() + recipient.id = option.attrib['value'] + recipient.label = option.text + yield recipient + + def ischecked(self, account): + id = account.id + # remove prefix (CC-, LA-, ...) + id = id[3:] + search = '//input[@value="%s"]' % id + option = self.document.xpath('//input[@value="%s"]' % id) + if len(option) < 0: + raise AccountNotFound() + else: + option = option[0] + try: + if option.attrib["checked"] == "checked": + return True + else: + return False + except: + return False