Convert CapBill to browser2, step 1
This commit is contained in:
parent
9026866488
commit
2ddd15fda9
2 changed files with 24 additions and 27 deletions
|
|
@ -215,13 +215,12 @@ class IngBrowser(LoginBrowser):
|
|||
|
||||
|
||||
############# CapBill #############
|
||||
@need_login
|
||||
def get_subscriptions(self):
|
||||
self.location('/protected/pages/common/estatement/eStatement.jsf')
|
||||
return self.page.iter_account()
|
||||
return self.billpage.stay_or_go().iter_account()
|
||||
|
||||
def get_bills(self, subscription):
|
||||
if not self.is_on_page(BillsPage):
|
||||
self.location(self.billpage)
|
||||
self.billpage.stay_or_go()
|
||||
data = {"AJAXREQUEST": "_viewRoot",
|
||||
"accountsel_form": "accountsel_form",
|
||||
subscription._formid: subscription._formid,
|
||||
|
|
@ -229,7 +228,7 @@ class IngBrowser(LoginBrowser):
|
|||
"javax.faces.ViewState": subscription._javax,
|
||||
"transfer_issuer_radio": subscription.id
|
||||
}
|
||||
self.location(self.billpage, urllib.urlencode(data))
|
||||
self.billpage.go(data=data)
|
||||
while True:
|
||||
for bill in self.page.iter_bills(subscription.id):
|
||||
yield bill
|
||||
|
|
|
|||
|
|
@ -19,34 +19,32 @@
|
|||
|
||||
from weboob.tools.mech import ClientForm
|
||||
from weboob.capabilities.bill import Bill, Subscription
|
||||
from weboob.tools.browser import BasePage
|
||||
from weboob.tools.browser2 import HTMLPage
|
||||
from weboob.tools.browser2.filters import Filter, Attr, CleanText
|
||||
from weboob.tools.browser2.page import ListElement, ItemElement, method
|
||||
|
||||
|
||||
__all__ = ['BillsPage']
|
||||
|
||||
class FormId(Filter):
|
||||
def filter(self, txt):
|
||||
formid = txt.split("parameters")[1]
|
||||
formid = txt.split("'")[2]
|
||||
return formid
|
||||
|
||||
class BillsPage(BasePage):
|
||||
def on_loaded(self):
|
||||
pass
|
||||
|
||||
def iter_account(self):
|
||||
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'):
|
||||
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._formid = formid
|
||||
subscription._javax = javax
|
||||
yield subscription
|
||||
class BillsPage(HTMLPage):
|
||||
@method
|
||||
class iter_account(ListElement):
|
||||
item_xpath = '//ul[@class="unstyled striped"]/li'
|
||||
|
||||
class item(ItemElement):
|
||||
klass = Subscription
|
||||
|
||||
obj__javax = Attr("//form[@id='accountsel_form']/input[@name='javax.faces.ViewState']", 'value')
|
||||
obj_id = Attr('input', "value")
|
||||
obj_label = CleanText('label')
|
||||
obj__formid = FormId(Attr('input', 'onclick'))
|
||||
|
||||
def postpredown(self, id):
|
||||
self.browser.select_form("statements_form")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue