support pagination
This commit is contained in:
parent
c0e3a1d6e2
commit
c207b109ab
4 changed files with 62 additions and 31 deletions
|
|
@ -96,21 +96,20 @@ class CICBrowser(BaseBrowser):
|
||||||
self.currentSubBank = url.path.lstrip('/').split('/')[0]
|
self.currentSubBank = url.path.lstrip('/').split('/')[0]
|
||||||
|
|
||||||
def list_operations(self, page_url):
|
def list_operations(self, page_url):
|
||||||
l_ret = []
|
|
||||||
while page_url:
|
|
||||||
if page_url.startswith('/'):
|
if page_url.startswith('/'):
|
||||||
self.location(page_url)
|
self.location(page_url)
|
||||||
else:
|
else:
|
||||||
self.location('https://%s/%s/fr/banque/%s' % (self.DOMAIN, self.currentSubBank, page_url))
|
self.location('https://%s/%s/fr/banque/%s' % (self.DOMAIN, self.currentSubBank, page_url))
|
||||||
|
|
||||||
|
go_next = True
|
||||||
|
while go_next:
|
||||||
if not self.is_on_page(OperationsPage):
|
if not self.is_on_page(OperationsPage):
|
||||||
break
|
return
|
||||||
|
|
||||||
for op in self.page.get_history():
|
for op in self.page.get_history():
|
||||||
l_ret.append(op)
|
yield op
|
||||||
page_url = self.page.next_page_url()
|
|
||||||
|
|
||||||
return l_ret
|
go_next = self.page.go_next()
|
||||||
|
|
||||||
def get_history(self, account):
|
def get_history(self, account):
|
||||||
transactions = []
|
transactions = []
|
||||||
|
|
@ -190,8 +189,3 @@ class CICBrowser(BaseBrowser):
|
||||||
transfer.recipient = to
|
transfer.recipient = to
|
||||||
transfer.date = submit_date
|
transfer.date = submit_date
|
||||||
return transfer
|
return transfer
|
||||||
|
|
||||||
#def get_coming_operations(self, account):
|
|
||||||
# if not self.is_on_page(AccountComing) or self.page.account.id != account.id:
|
|
||||||
# self.location('/NS_AVEEC?ch4=%s' % account._link_id)
|
|
||||||
# return self.page.get_operations()
|
|
||||||
|
|
|
||||||
|
|
@ -146,9 +146,28 @@ class OperationsPage(BasePage):
|
||||||
operation.set_amount(credit, debit)
|
operation.set_amount(credit, debit)
|
||||||
yield operation
|
yield operation
|
||||||
|
|
||||||
def next_page_url(self):
|
def go_next(self):
|
||||||
""" TODO pouvoir passer à la page des opérations suivantes """
|
form = self.document.xpath('//form[@id="paginationForm"]')
|
||||||
return 0
|
if len(form) == 0:
|
||||||
|
return False
|
||||||
|
|
||||||
|
text = self.parser.tocleanstring(form[0])
|
||||||
|
m = re.search(u'(\d+) / (\d+)', text or '', flags=re.MULTILINE)
|
||||||
|
if not m:
|
||||||
|
return False
|
||||||
|
|
||||||
|
cur = int(m.group(1))
|
||||||
|
last = int(m.group(2))
|
||||||
|
|
||||||
|
if cur == last:
|
||||||
|
return False
|
||||||
|
|
||||||
|
self.browser.select_form(name='paginationForm')
|
||||||
|
self.browser.set_all_readonly(False)
|
||||||
|
self.browser['page'] = str(cur + 1)
|
||||||
|
self.browser.submit()
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
class CardPage(OperationsPage):
|
class CardPage(OperationsPage):
|
||||||
def get_history(self):
|
def get_history(self):
|
||||||
|
|
|
||||||
|
|
@ -97,21 +97,20 @@ class CreditMutuelBrowser(BaseBrowser):
|
||||||
self.currentSubBank = url.path.lstrip('/').split('/')[0]
|
self.currentSubBank = url.path.lstrip('/').split('/')[0]
|
||||||
|
|
||||||
def list_operations(self, page_url):
|
def list_operations(self, page_url):
|
||||||
l_ret = []
|
|
||||||
while page_url:
|
|
||||||
if page_url.startswith('/'):
|
if page_url.startswith('/'):
|
||||||
self.location(page_url)
|
self.location(page_url)
|
||||||
else:
|
else:
|
||||||
self.location('https://%s/%s/fr/banque/%s' % (self.DOMAIN, self.currentSubBank, page_url))
|
self.location('https://%s/%s/fr/banque/%s' % (self.DOMAIN, self.currentSubBank, page_url))
|
||||||
|
|
||||||
|
go_next = True
|
||||||
|
while go_next:
|
||||||
if not self.is_on_page(OperationsPage):
|
if not self.is_on_page(OperationsPage):
|
||||||
break
|
return
|
||||||
|
|
||||||
for op in self.page.get_history():
|
for op in self.page.get_history():
|
||||||
l_ret.append(op)
|
yield op
|
||||||
page_url = self.page.next_page_url()
|
|
||||||
|
|
||||||
return l_ret
|
go_next = self.page.go_next()
|
||||||
|
|
||||||
def get_history(self, account):
|
def get_history(self, account):
|
||||||
transactions = []
|
transactions = []
|
||||||
|
|
|
||||||
|
|
@ -146,9 +146,28 @@ class OperationsPage(BasePage):
|
||||||
operation.set_amount(credit, debit)
|
operation.set_amount(credit, debit)
|
||||||
yield operation
|
yield operation
|
||||||
|
|
||||||
def next_page_url(self):
|
def go_next(self):
|
||||||
""" TODO pouvoir passer à la page des opérations suivantes """
|
form = self.document.xpath('//form[@id="paginationForm"]')
|
||||||
return 0
|
if len(form) == 0:
|
||||||
|
return False
|
||||||
|
|
||||||
|
text = self.parser.tocleanstring(form[0])
|
||||||
|
m = re.search(u'(\d+) / (\d+)', text or '', flags=re.MULTILINE)
|
||||||
|
if not m:
|
||||||
|
return False
|
||||||
|
|
||||||
|
cur = int(m.group(1))
|
||||||
|
last = int(m.group(2))
|
||||||
|
|
||||||
|
if cur == last:
|
||||||
|
return False
|
||||||
|
|
||||||
|
self.browser.select_form(name='paginationForm')
|
||||||
|
self.browser.set_all_readonly(False)
|
||||||
|
self.browser['page'] = str(cur + 1)
|
||||||
|
self.browser.submit()
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
class CardPage(OperationsPage):
|
class CardPage(OperationsPage):
|
||||||
def get_history(self):
|
def get_history(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue