Convert iter_bills and postpredown
This commit is contained in:
parent
2ddd15fda9
commit
b79215733c
2 changed files with 21 additions and 38 deletions
|
|
@ -229,13 +229,7 @@ class IngBrowser(LoginBrowser):
|
||||||
"transfer_issuer_radio": subscription.id
|
"transfer_issuer_radio": subscription.id
|
||||||
}
|
}
|
||||||
self.billpage.go(data=data)
|
self.billpage.go(data=data)
|
||||||
while True:
|
return self.page.iter_bills(subid=subscription.id)
|
||||||
for bill in self.page.iter_bills(subscription.id):
|
|
||||||
yield bill
|
|
||||||
if self.page.islast():
|
|
||||||
return
|
|
||||||
|
|
||||||
self.page.next_page()
|
|
||||||
|
|
||||||
def predownload(self, bill):
|
def predownload(self, bill):
|
||||||
self.page.postpredown(bill._localid)
|
self.page.postpredown(localid=bill._localid)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright(C) 2009-2012 Romain Bignon, Florent Fourcot
|
# Copyright(C) 2009-2014 Florent Fourcot
|
||||||
#
|
#
|
||||||
# This file is part of weboob.
|
# This file is part of weboob.
|
||||||
#
|
#
|
||||||
|
|
@ -17,10 +17,9 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# 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.capabilities.bill import Bill, Subscription
|
||||||
from weboob.tools.browser2 import HTMLPage
|
from weboob.tools.browser2 import HTMLPage
|
||||||
from weboob.tools.browser2.filters import Filter, Attr, CleanText
|
from weboob.tools.browser2.filters import Filter, Attr, CleanText, Format, Field, Env
|
||||||
from weboob.tools.browser2.page import ListElement, ItemElement, method
|
from weboob.tools.browser2.page import ListElement, ItemElement, method
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -46,33 +45,23 @@ class BillsPage(HTMLPage):
|
||||||
obj_label = CleanText('label')
|
obj_label = CleanText('label')
|
||||||
obj__formid = FormId(Attr('input', 'onclick'))
|
obj__formid = FormId(Attr('input', 'onclick'))
|
||||||
|
|
||||||
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):
|
def postpredown(self, _id):
|
||||||
return True
|
_id = _id.split("'")[5]
|
||||||
|
form = self.get_form(name="statements_form")
|
||||||
|
form['AJAXREQUEST'] = 'statements_form:stat_region'
|
||||||
|
form['id'] = _id
|
||||||
|
form.submit()
|
||||||
|
|
||||||
def next_page(self):
|
@method
|
||||||
pass
|
class iter_bills(ListElement):
|
||||||
|
item_xpath = '//ul[@id="statements_form:statementsel"]/li'
|
||||||
|
|
||||||
def iter_bills(self, subscriptionid):
|
class item(ItemElement):
|
||||||
ul = self.document.xpath('//ul[@id="statements_form:statementsel"]')
|
klass = Bill
|
||||||
lis = ul[0].xpath('li')
|
|
||||||
lis.pop(0) # Select alls
|
obj_label = CleanText('a[1]')
|
||||||
for li in lis:
|
obj_id = Format(u"%s-%s", Env('subid'), Field('label'))
|
||||||
acheck = li.xpath('a')[0]
|
obj_format = u"pdf"
|
||||||
adirect = li.xpath('a')[1]
|
obj__url = Attr('a[2]', 'href')
|
||||||
label = unicode(acheck.text_content())
|
obj__localid = Attr('a[2]', 'onmouseover')
|
||||||
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