Support of downloading monthly pdf report
This commit is contained in:
parent
5809f1112a
commit
8377407155
4 changed files with 136 additions and 5 deletions
|
|
@ -22,16 +22,16 @@
|
|||
from __future__ import with_statement
|
||||
|
||||
from weboob.capabilities.bank import ICapBank, AccountNotFound, Account, Recipient
|
||||
from weboob.capabilities.bill import ICapBill, Bill, Subscription, SubscriptionNotFound, BillNotFound
|
||||
from weboob.tools.backend import BaseBackend, BackendConfig
|
||||
from weboob.tools.value import ValueBackendPassword
|
||||
|
||||
from .browser import Ing
|
||||
|
||||
|
||||
__all__ = ['INGBackend']
|
||||
|
||||
|
||||
class INGBackend(BaseBackend, ICapBank):
|
||||
class INGBackend(BaseBackend, ICapBank, ICapBill):
|
||||
NAME = 'ing'
|
||||
MAINTAINER = u'Florent Fourcot'
|
||||
EMAIL = 'weboob@flo.fourcot.fr'
|
||||
|
|
@ -89,3 +89,32 @@ class INGBackend(BaseBackend, ICapBank):
|
|||
if "-" in recipient:
|
||||
recipient = recipient[3:]
|
||||
return self.browser.transfer(account, recipient, amount, reason)
|
||||
|
||||
def iter_subscription(self):
|
||||
for subscription in self.browser.get_subscriptions():
|
||||
yield subscription
|
||||
|
||||
def get_subscription(self, _id):
|
||||
for subscription in self.browser.get_subscriptions():
|
||||
if subscription.id == _id:
|
||||
return subscription
|
||||
raise SubscriptionNotFound()
|
||||
|
||||
def get_bill(self, id):
|
||||
subscription = self.get_subscription(id.split('-')[0])
|
||||
for bill in self.browser.get_bills(subscription):
|
||||
if bill.id == id:
|
||||
return bill
|
||||
raise BillNotFound()
|
||||
|
||||
def iter_bills(self, subscription):
|
||||
if not isinstance(subscription, Subscription):
|
||||
subscription = self.get_subscription(subscription)
|
||||
return self.browser.get_bills(subscription)
|
||||
|
||||
def download_bill(self, bill):
|
||||
if not isinstance(bill, Bill):
|
||||
bill = self.get_bill(bill)
|
||||
self.browser.predownload(bill)
|
||||
with self.browser:
|
||||
return self.browser.readurl("https://secure.ingdirect.fr" + bill._url)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@ import hashlib
|
|||
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
|
||||
from weboob.capabilities.bank import Account, TransferError
|
||||
from .pages import AccountsList, LoginPage, LoginPage2, \
|
||||
AccountHistory, TransferPage, TransferConfirmPage
|
||||
AccountHistory, TransferPage, TransferConfirmPage, \
|
||||
BillsPage
|
||||
|
||||
|
||||
__all__ = ['Ing']
|
||||
|
|
@ -41,7 +42,8 @@ class Ing(BaseBrowser):
|
|||
'.*transferManagement.jsf': TransferPage,
|
||||
'.*onHoldTransferManagement.jsf': TransferPage,
|
||||
'.*DisplayDoTransferCommand.*': TransferPage,
|
||||
'.*transferCreateValidation.jsf': TransferConfirmPage
|
||||
'.*transferCreateValidation.jsf': TransferConfirmPage,
|
||||
'.*eStatement.jsf': BillsPage
|
||||
}
|
||||
CERTHASH = "fba557b387cccc3d71ba038f9ef1de4d71541d7954744c79f6a7ff5f3cd4dc12"
|
||||
|
||||
|
|
@ -154,3 +156,21 @@ class Ing(BaseBrowser):
|
|||
return self.page.recap()
|
||||
else:
|
||||
raise TransferError('Recipient not found')
|
||||
|
||||
def get_subscriptions(self):
|
||||
self.location('https://secure.ingdirect.fr/protected/pages/common/estatement/eStatement.jsf')
|
||||
return self.page.iter_account()
|
||||
|
||||
def get_bills(self, subscription):
|
||||
if not self.is_on_page(BillsPage):
|
||||
self.location('https://secure.ingdirect.fr/protected/pages/common/estatement/eStatement.jsf')
|
||||
self.page.selectyear(subscription._localid)
|
||||
while 1:
|
||||
for bill in self.page.iter_bills(subscription.id):
|
||||
yield bill
|
||||
if self.page.islast():
|
||||
return
|
||||
self.page.next_page()
|
||||
|
||||
def predownload(self, bill):
|
||||
self.page.postpredown(bill._localid)
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ from .accounts_list import AccountsList
|
|||
from .account_history import AccountHistory
|
||||
from .login import LoginPage, LoginPage2
|
||||
from .transfer import TransferPage, TransferConfirmPage
|
||||
from .bills import BillsPage
|
||||
|
||||
|
||||
class AccountPrelevement(AccountsList):
|
||||
|
|
@ -29,4 +30,5 @@ class AccountPrelevement(AccountsList):
|
|||
|
||||
__all__ = ['AccountsList', 'AccountHistory', 'LoginPage',
|
||||
'LoginPage2', 'AccountPrelevement',
|
||||
'TransferPage', 'TransferConfirmPage']
|
||||
'TransferPage', 'TransferConfirmPage',
|
||||
'BillsPage']
|
||||
|
|
|
|||
80
modules/ing/pages/bills.py
Normal file
80
modules/ing/pages/bills.py
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright(C) 2009-2012 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
from weboob.tools.mech import ClientForm
|
||||
from weboob.capabilities.bill import Bill, Subscription
|
||||
from weboob.tools.browser import BasePage
|
||||
|
||||
|
||||
__all__ = ['BillsPage']
|
||||
|
||||
|
||||
class BillsPage(BasePage):
|
||||
def on_loaded(self):
|
||||
pass
|
||||
|
||||
def iter_account(self):
|
||||
ul = self.document.xpath('//ul[@id="accountsel_form:accountsel"]')
|
||||
#subscriber = unicode(self.document.find('//h5').text)
|
||||
for li in ul[0].xpath('li/a'):
|
||||
label = li.text
|
||||
id = label.split(' ')[-1]
|
||||
subscription = Subscription(id)
|
||||
subscription.label = label
|
||||
# subscription.subscriber = subscriber
|
||||
subscription._localid = li.attrib['id']
|
||||
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)
|
||||
self.browser.controls.append(ClientForm.TextControl('text', 'AJAXREQUEST', {'value': 'statements_form:stat_region'}))
|
||||
self.browser.controls.append(ClientForm.TextControl('text', id, {'value': id}))
|
||||
self.browser.submit(nologin=True)
|
||||
|
||||
def islast(self):
|
||||
return True
|
||||
|
||||
def next_page(self):
|
||||
pass
|
||||
|
||||
def iter_bills(self, subscriptionid):
|
||||
ul = self.document.xpath('//ul[@id="statements_form:statementsel"]')
|
||||
lis = ul[0].xpath('li')
|
||||
lis.pop(0) # Select alls
|
||||
for li in lis:
|
||||
acheck = li.xpath('a')[0]
|
||||
adirect = li.xpath('a')[1]
|
||||
label = unicode(acheck.text_content())
|
||||
id = subscriptionid + '-' + label.replace(' ', '-')
|
||||
bill = Bill()
|
||||
bill.id = id
|
||||
bill.label = label
|
||||
bill.format = u"pdf"
|
||||
onmouse = adirect.attrib['onmouseover']
|
||||
bill._localid = onmouse.split("'")[5]
|
||||
bill._url = adirect.attrib['href']
|
||||
yield bill
|
||||
Loading…
Add table
Add a link
Reference in a new issue