[hellobank] Allow transaction parsing across multiple pages.
This commit is contained in:
parent
273e15928d
commit
6c12d3d063
2 changed files with 56 additions and 9 deletions
38
modules/hellobank/browser.py
Normal file → Executable file
38
modules/hellobank/browser.py
Normal file → Executable file
|
|
@ -105,16 +105,17 @@ class HelloBank(Browser):
|
|||
|
||||
def get_IBAN_from_account(self, account):
|
||||
self.go_to_history_page(account)
|
||||
return self.page.get_IBAN()
|
||||
return self.page.get_IBAN()[5:21]
|
||||
|
||||
def go_to_history_page(self,account):
|
||||
def go_to_history_page(self, account, page = None):
|
||||
if account._link_id is None:
|
||||
raise NotImplementedError()
|
||||
|
||||
if not self.is_on_page(AccountsList):
|
||||
self.location('/NSFR?Action=DSP_VGLOBALE')
|
||||
if (page == None):
|
||||
if not self.is_on_page(AccountsList):
|
||||
self.location('/NSFR?Action=DSP_VGLOBALE')
|
||||
|
||||
data = {'gt': 'homepage:basic-theme',
|
||||
data = {'gt': 'homepage:basic-theme',
|
||||
'externalIAId': 'IAStatements',
|
||||
'cboFlowName': 'flow/iastatement',
|
||||
'contractId': account._link_id,
|
||||
|
|
@ -123,8 +124,24 @@ class HelloBank(Browser):
|
|||
'groupSelected':'-2',
|
||||
'step': 'STAMENTS',
|
||||
'pageId': 'releveoperations',
|
||||
'sendEUD': 'true',
|
||||
'sendEUD': 'true'
|
||||
}
|
||||
else:
|
||||
data = {'_eventId': 'gotoPage',
|
||||
'contractId': self.page.get_IBAN(),
|
||||
'groupId': '-2',
|
||||
'pageId': 'releveoperations',
|
||||
'operations.pageNumber': page,
|
||||
'categorisationInProgress': '',
|
||||
'newCategoryId': '',
|
||||
'operations.objectsPerPage': '30',
|
||||
'_flowExecutionKey': self.page.get_flowExecutionKey(),
|
||||
}
|
||||
for i in range(0,30):
|
||||
data.update({"operations.list[" + str(i) + "].extendedAttributes['audience']": 'particulier',
|
||||
"_operations.list[" + str(i) + "].checkedOff": 'on',
|
||||
"_operations.list[" + str(i) + "].selectedForCategorization": 'on'})
|
||||
|
||||
self.location('/udc', urllib.urlencode(data))
|
||||
|
||||
def go_to_coming_operations_page(self,account):
|
||||
|
|
@ -149,7 +166,14 @@ class HelloBank(Browser):
|
|||
|
||||
def iter_history(self, account):
|
||||
self.go_to_history_page(account)
|
||||
return self.page.iter_operations()
|
||||
for tr in self.page.get_operations():
|
||||
yield tr
|
||||
next_page = self.page.get_next_page()
|
||||
while( next_page > 1) :
|
||||
self.go_to_history_page(account, next_page)
|
||||
for tr in self.page.get_operations():
|
||||
yield tr
|
||||
next_page = self.page.get_next_page()
|
||||
|
||||
def iter_coming_operations(self, account):
|
||||
self.go_to_coming_operations_page(account)
|
||||
|
|
|
|||
27
modules/hellobank/perso/transactions.py
Normal file → Executable file
27
modules/hellobank/perso/transactions.py
Normal file → Executable file
|
|
@ -46,7 +46,7 @@ class Transaction(FrenchTransaction):
|
|||
|
||||
|
||||
class AccountHistory(Page):
|
||||
def iter_operations(self):
|
||||
def get_operations(self):
|
||||
for tr in self.document.xpath('//table[@id="tableCompte"]//tr'):
|
||||
if len(tr.xpath('td[@class="debit"]')) == 0:
|
||||
continue
|
||||
|
|
@ -86,8 +86,31 @@ class AccountHistory(Page):
|
|||
operation.set_amount(tds[2].text)
|
||||
yield operation
|
||||
|
||||
def get_next_page(self):
|
||||
others = self.document.xpath('//span[@class="OthersPage"]')
|
||||
current = self.document.xpath('//span[@class="currentPage"]/strong')
|
||||
|
||||
if len(current) < 1:
|
||||
return None
|
||||
|
||||
current = current[0].text
|
||||
for other in others:
|
||||
if (other.text <= current):
|
||||
continue
|
||||
else:
|
||||
return other.text
|
||||
|
||||
return None
|
||||
|
||||
def get_flowExecutionKey(self):
|
||||
flowExecutionKey = self.document.xpath('//input[@name="_flowExecutionKey"]/@value')
|
||||
if len(flowExecutionKey) > 0:
|
||||
return flowExecutionKey[0]
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_IBAN(self):
|
||||
return self.document.xpath('//a[@class="lien_perso_libelle"]')[0].attrib['id'][10:26]
|
||||
return self.document.xpath('//a[@class="lien_perso_libelle"]')[0].attrib['id'][5:28]
|
||||
|
||||
|
||||
class AccountComing(AccountHistory):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue