Download bill on freemobile
This commit is contained in:
parent
006e97a8be
commit
99a2e554e8
5 changed files with 82 additions and 9 deletions
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
from __future__ import with_statement
|
||||
|
||||
from weboob.capabilities.bill import ICapBill, SubscriptionNotFound
|
||||
from weboob.capabilities.bill import ICapBill, SubscriptionNotFound, BillNotFound
|
||||
from weboob.tools.backend import BaseBackend, BackendConfig
|
||||
from weboob.tools.value import ValueBackendPassword
|
||||
|
||||
|
|
@ -68,14 +68,18 @@ class FreeMobileBackend(BaseBackend, ICapBill):
|
|||
for history in self.browser.get_history():
|
||||
yield history
|
||||
|
||||
def get_bill(self, subscription, id):
|
||||
raise NotImplementedError()
|
||||
def get_bill(self, id):
|
||||
with self.browser:
|
||||
bill = self.browser.get_bill(id)
|
||||
if bill:
|
||||
return bill
|
||||
else:
|
||||
raise BillNotFound()
|
||||
|
||||
def iter_bills(self, subscription):
|
||||
with self.browser:
|
||||
sub = self.get_subscription(subscription)
|
||||
for bill in self.browser.iter_bills():
|
||||
bill.idparent = sub.id
|
||||
for bill in self.browser.iter_bills(sub.id):
|
||||
yield bill
|
||||
|
||||
# The subscription is actually useless, but maybe for the futur...
|
||||
|
|
@ -83,3 +87,7 @@ class FreeMobileBackend(BaseBackend, ICapBill):
|
|||
with self.browser:
|
||||
for detail in self.browser.get_details():
|
||||
yield detail
|
||||
|
||||
def download_bill(self, id):
|
||||
with self.browser:
|
||||
return self.browser.download_bill(id)
|
||||
|
|
|
|||
|
|
@ -85,7 +85,23 @@ class Freemobile(BaseBrowser):
|
|||
self.location('/moncompte/index.php?page=suiviconso')
|
||||
return self.page.get_details()
|
||||
|
||||
def iter_bills(self):
|
||||
def iter_bills(self, parentid):
|
||||
if not self.is_on_page(DetailsPage):
|
||||
self.location('/moncompte/index.php?page=suiviconso')
|
||||
return self.page.date_bills()
|
||||
|
||||
def get_bill(self, id):
|
||||
assert isinstance(id, basestring)
|
||||
|
||||
if not self.is_on_page(DetailsPage):
|
||||
self.location('/moncompte/index.php?page=suiviconso')
|
||||
l = self.page.date_bills()
|
||||
for a in l:
|
||||
if a.id == id:
|
||||
return a
|
||||
|
||||
def download_bill(self, id):
|
||||
assert isinstance(id, basestring)
|
||||
date = id.split('.')[1]
|
||||
|
||||
return self.readurl('/moncompte/ajax.php?page=facture&mode=html&date=' + date)
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@ class DetailsPage(BasePage):
|
|||
|
||||
def on_loaded(self):
|
||||
|
||||
num = self.document.xpath('//div[@class="infosLigneDetail"]')[0].text
|
||||
num = num.split("-")[2].strip()
|
||||
divnat = self.document.xpath('//div[@class="national"]')[0]
|
||||
divs = divnat.xpath('div[@class="detail"]')
|
||||
divvoice = divs.pop(0)
|
||||
|
|
@ -62,6 +64,7 @@ class DetailsPage(BasePage):
|
|||
mydate = trbill.find('td/input').attrib['onclick'].split("'")[1]
|
||||
bill = Bill()
|
||||
bill.label = mydate
|
||||
bill.id = num + "." + mydate
|
||||
bill.date = date(int(mydate[0:4]), int(mydate[4:6]), int(mydate[6:8]))
|
||||
bill.format = 'html'
|
||||
self.datebills.append(bill)
|
||||
|
|
@ -78,7 +81,7 @@ class DetailsPage(BasePage):
|
|||
|
||||
self.details.append(detail)
|
||||
|
||||
def get_details(self):
|
||||
def get_details(self, parentid):
|
||||
return self.details
|
||||
|
||||
def date_bills(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue