From e35c7812ea8bc37b857173be234049168060d5fc Mon Sep 17 00:00:00 2001 From: Florent Date: Tue, 8 Jan 2013 20:52:30 +0100 Subject: [PATCH] Get renew date on freemobile --- modules/freemobile/browser.py | 6 +++++- modules/freemobile/pages/history.py | 12 ++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/modules/freemobile/browser.py b/modules/freemobile/browser.py index b161d290..7e7c59f6 100644 --- a/modules/freemobile/browser.py +++ b/modules/freemobile/browser.py @@ -59,7 +59,11 @@ class Freemobile(BaseBrowser): if not self.is_on_page(HomePage): self.location('/moncompte/index.php?page=home') - return self.page.get_list() + subscriptions = self.page.get_list() + self.location('/moncompte/index.php?page=suiviconso') + for subscription in subscriptions: + subscription.renewdate = self.page.get_renew_date(subscription) + yield subscription def get_subscription(self, id): assert isinstance(id, basestring) diff --git a/modules/freemobile/pages/history.py b/modules/freemobile/pages/history.py index 83977843..f1194264 100644 --- a/modules/freemobile/pages/history.py +++ b/modules/freemobile/pages/history.py @@ -48,6 +48,7 @@ class DetailsPage(BasePage): virtualnumber = div.attrib['onclick'].split('(')[1][1] self.details['num' + str(phonenumber)] = virtualnumber + for div in self.document.xpath('//div[@class="infosConso"]'): num = div.attrib['id'].split('_')[1][0] self.details[num] = [] @@ -123,6 +124,17 @@ class DetailsPage(BasePage): def date_bills(self): return self.datebills + def get_renew_date(self, subscription): + div = self.document.xpath('//div[@class="resumeConso"]')[0] + mydate = div.xpath('span[@class="actif"]')[0].text + mydate = date(*reversed([int(x) for x in mydate.split("/")])) + if mydate.month == 12: + mydate = mydate.replace(month = 1) + mydate = mydate.replace(year= mydate.year + 1) + else: + mydate = mydate.replace(month = mydate.month + 1) + return mydate + def _get_date(detail): return detail.datetime