Make history working with browser2
This commit is contained in:
parent
25725f79cf
commit
e8c387aa02
2 changed files with 12 additions and 12 deletions
|
|
@ -49,12 +49,13 @@ class Freemobile(LoginBrowser):
|
|||
|
||||
self.detailspage.go()
|
||||
for subscription in subscriptions:
|
||||
subscription._virtual = self.page.load_virtual(subscription.id)
|
||||
subscription.renewdate = self.page.get_renew_date(subscription)
|
||||
yield subscription
|
||||
|
||||
def get_history(self, subscription):
|
||||
self.historypage.go(data={'login': subscription._login})
|
||||
return self.page.get_calls()
|
||||
return sorted([x for x in self.page.get_calls()], key=lambda self: self.datetime, reverse=True)
|
||||
|
||||
def get_details(self, subscription):
|
||||
return self.detailspage.stay_or_go().get_details(subscription)
|
||||
|
|
|
|||
|
|
@ -45,14 +45,13 @@ class BadUTF8Page(HTMLPage):
|
|||
|
||||
|
||||
class DetailsPage(LoggedPage, BadUTF8Page):
|
||||
def load_virtual(self, phonenumber):
|
||||
for div in self.doc.xpath('//div[@class="infosLigne pointer"]'):
|
||||
if CleanText('.')(div).split("-")[-1].strip() == phonenumber:
|
||||
return Attr('.', 'onclick')(div).split('(')[1][1]
|
||||
|
||||
def on_load(self):
|
||||
self.details = {}
|
||||
for div in self.doc.xpath('//div[@class="infosLigne pointer"]'):
|
||||
phonenumber = CleanText('.')(div)
|
||||
phonenumber = phonenumber.split("-")[-1].strip()
|
||||
virtualnumber = div.attrib['onclick'].split('(')[1][1]
|
||||
self.details['num' + str(phonenumber)] = virtualnumber
|
||||
|
||||
for div in self.doc.xpath('//div[@class="infosConso"]'):
|
||||
num = div.attrib['id'].split('_')[1][0]
|
||||
self.details[num] = []
|
||||
|
|
@ -104,8 +103,7 @@ class DetailsPage(LoggedPage, BadUTF8Page):
|
|||
|
||||
# XXX
|
||||
def get_details(self, subscription):
|
||||
num = self.details['num' + subscription.id]
|
||||
for detail in self.details[num]:
|
||||
for detail in self.details[subscription._virtual]:
|
||||
detail.id = subscription.id + detail.id
|
||||
yield detail
|
||||
|
||||
|
|
@ -151,7 +149,8 @@ class HistoryPage(LoggedPage, BadUTF8Page):
|
|||
txt = self.el.xpath('td[1]')[0].text
|
||||
return (txt is not None) and (txt != "Date")
|
||||
|
||||
obj_datetime = DateTime(CleanText('td[1]'), dayfirst=True)
|
||||
obj_label = Format(u'%s %s %s %s', CleanText('td[2]'), CleanText('td[3]'),
|
||||
CleanText('td[4]'), CleanText('td[5]'))
|
||||
obj_id = None
|
||||
obj_datetime = DateTime(CleanText('td[1]', symbols=u'à'), dayfirst=True)
|
||||
obj_label = Format(u'%s %s %s', CleanText('td[2]'), CleanText('td[3]'),
|
||||
CleanText('td[4]'))
|
||||
obj_price = CleanDecimal('td[5]', default=Decimal(0))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue