Get renew date on freemobile

This commit is contained in:
Florent 2013-01-08 20:52:30 +01:00
commit e35c7812ea
2 changed files with 17 additions and 1 deletions

View file

@ -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)

View file

@ -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