Search bills on freemobile

This commit is contained in:
Florent 2012-03-13 21:39:18 +01:00 committed by Romain Bignon
commit c890fe26d7
3 changed files with 26 additions and 6 deletions

View file

@ -68,11 +68,15 @@ class FreeMobileBackend(BaseBackend, ICapBill):
for history in self.browser.get_history():
yield history
def get_get_bill(self, subscription, id):
def get_bill(self, subscription, id):
raise NotImplementedError()
def iter_bill(self, subscription):
raise NotImplementedError()
def iter_bills(self, subscription):
with self.browser:
sub = self.get_subscription(subscription)
for bill in self.browser.iter_bills():
bill.idparent = sub.id
yield bill
# The subscription is actually useless, but maybe for the futur...
def get_details(self, subscription):

View file

@ -83,5 +83,9 @@ class Freemobile(BaseBrowser):
def get_details(self):
if not self.is_on_page(DetailsPage):
self.location('/moncompte/index.php?page=suiviconso')
test = self.page.get_details()
return test
return self.page.get_details()
def iter_bills(self):
if not self.is_on_page(DetailsPage):
self.location('/moncompte/index.php?page=suiviconso')
return self.page.date_bills()

View file

@ -19,7 +19,7 @@
from weboob.tools.browser import BasePage
from weboob.capabilities.bill import Detail
from weboob.capabilities.bill import Detail, Bill
from datetime import datetime, date, time
@ -37,6 +37,7 @@ def convert_price(div):
class DetailsPage(BasePage):
details = []
datebills = []
def on_loaded(self):
@ -57,6 +58,14 @@ class DetailsPage(BasePage):
divint = self.document.xpath('//div[@class="international hide"]')[0]
self.iter_divs(divint.xpath('div[@class="detail"]'), True)
for trbill in self.document.xpath('//tr[@class="derniereFacture"]'):
mydate = trbill.find('td/input').attrib['onclick'].split("'")[1]
bill = Bill()
bill.label = mydate
bill.date = date(int(mydate[0:4]), int(mydate[4:6]), int(mydate[6:8]))
bill.format = 'html'
self.datebills.append(bill)
def iter_divs(self, divs, inter=False):
for div in divs:
detail = Detail()
@ -72,6 +81,9 @@ class DetailsPage(BasePage):
def get_details(self):
return self.details
def date_bills(self):
return self.datebills
def _get_date(detail):
return detail.datetime