Support bills and download operations
This commit is contained in:
parent
8fa430e61f
commit
f33af8ff50
2 changed files with 18 additions and 7 deletions
|
|
@ -120,14 +120,12 @@ class Leclercmobile(BaseBrowser):
|
|||
def iter_bills(self, parentid):
|
||||
if not self.is_on_page(HistoryPage):
|
||||
self.location(self.conso)
|
||||
return self.page.date_bills()
|
||||
return self.page.date_bills(parentid)
|
||||
|
||||
def get_bill(self, id):
|
||||
assert isinstance(id, basestring)
|
||||
|
||||
if not self.is_on_page(HistoryPage):
|
||||
self.location(self.conso)
|
||||
l = self.page.date_bills()
|
||||
parentid = id[0:10]
|
||||
l = self.page.date_bills(parentid)
|
||||
for a in l:
|
||||
if a.id == id:
|
||||
return a
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ from datetime import datetime, date, time
|
|||
from decimal import Decimal
|
||||
|
||||
from weboob.tools.browser import BasePage
|
||||
from weboob.capabilities.bill import Detail
|
||||
from weboob.capabilities.bill import Detail, Bill
|
||||
|
||||
|
||||
__all__ = ['HistoryPage', 'PdfPage']
|
||||
|
|
@ -62,7 +62,7 @@ class PdfPage():
|
|||
lines = page.split('\n')
|
||||
lines = [x for x in lines if len(x) > 0] # Remove empty lines
|
||||
numitems = (len(lines) + 1) / 3 # Each line has three columns
|
||||
lines.insert(len(lines), '') # Add an empty column for "Prélèvement mensuel
|
||||
lines.insert(len(lines) - 1, '') # Add an empty column for "Prélèvement mensuel
|
||||
lines.pop(0)
|
||||
details = []
|
||||
for i in range(numitems):
|
||||
|
|
@ -134,3 +134,16 @@ class HistoryPage(BasePage):
|
|||
while len(self.document.xpath('//li[@id="liMois%s"]' % max)) > 0:
|
||||
max += 1
|
||||
return max - 1
|
||||
|
||||
def date_bills(self, parentid):
|
||||
max = 1
|
||||
while len(self.document.xpath('//li[@id="liMois%s"]' % max)) > 0:
|
||||
li = self.document.xpath('//li[@id="liMois%s"]' % max)[0]
|
||||
max += 1
|
||||
link = li.xpath('a')[0]
|
||||
bill = Bill()
|
||||
bill._url = link.attrib['href']
|
||||
bill.label = link.text
|
||||
bill.format = u"pdf"
|
||||
bill.id = parentid + bill.label.replace(' ', '')
|
||||
yield bill
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue