CrAgr: now handles history-less accounts, at least for Toulouse-like layouts
This commit is contained in:
parent
58b825c463
commit
0734e5d21c
2 changed files with 15 additions and 4 deletions
|
|
@ -131,6 +131,9 @@ class Cragr(BaseBrowser):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_history(self, account):
|
def get_history(self, account):
|
||||||
|
# some accounts may exist without a link to any history page
|
||||||
|
if account.link_id is None:
|
||||||
|
return
|
||||||
history_url = account.link_id
|
history_url = account.link_id
|
||||||
operations_count = 0
|
operations_count = 0
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,17 +46,25 @@ class AccountsList(CragrBasePage):
|
||||||
account = Account()
|
account = Account()
|
||||||
if div.getchildren()[0].tag == 'a':
|
if div.getchildren()[0].tag == 'a':
|
||||||
# This is at least present on CA Nord-Est
|
# This is at least present on CA Nord-Est
|
||||||
|
# Note: we do not know yet how history-less accounts are displayed by this layout
|
||||||
account.label = ' '.join(div.find('a').text.split()[:-1])
|
account.label = ' '.join(div.find('a').text.split()[:-1])
|
||||||
account.link_id = div.find('a').get('href', '')
|
account.link_id = div.find('a').get('href', '')
|
||||||
account.id = div.find('a').text.split()[-1]
|
account.id = div.find('a').text.split()[-1]
|
||||||
s = div.find('div').find('b').find('span').text
|
s = div.find('div').find('b').find('span').text
|
||||||
else:
|
else:
|
||||||
# This is at least present on CA Toulouse
|
# This is at least present on CA Toulouse
|
||||||
account.label = div.find('a').text.strip()
|
first_link = div.find('a')
|
||||||
account.link_id = div.find('a').get('href', '')
|
if first_link is not None:
|
||||||
|
account.label = first_link.text.strip()
|
||||||
|
account.link_id = first_link.get('href', '')
|
||||||
|
else:
|
||||||
|
# there is no link to any history page for accounts like "PEA" or "TITRES"
|
||||||
|
account.label = div.findall('br')[0].tail.strip()
|
||||||
|
account.link_id = None
|
||||||
account.id = div.findall('br')[1].tail.strip()
|
account.id = div.findall('br')[1].tail.strip()
|
||||||
s = div.find('div').find('b').text
|
s = div.xpath('//b')[-1].text
|
||||||
account.balance = clean_amount(s)
|
account.balance = clean_amount(s)
|
||||||
|
if account.label:
|
||||||
l.append(account)
|
l.append(account)
|
||||||
return l
|
return l
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue