Commit fa6dd434 authored by Baptiste Delpey's avatar Baptiste Delpey Committed by Romain Bignon

using TableElement and always get accounts url

parent 8a1b9c94
......@@ -21,8 +21,8 @@ import requests
from weboob.browser.pages import HTMLPage, CsvPage, pagination
from weboob.exceptions import BrowserIncorrectPassword
from weboob.browser.elements import ListElement, DictElement, ItemElement, method
from weboob.browser.filters.standard import CleanText, CleanDecimal, Date, Env
from weboob.browser.elements import DictElement, ItemElement, method, TableElement
from weboob.browser.filters.standard import CleanText, CleanDecimal, Date, Env, TableCell
from weboob.browser.filters.json import Dict
from weboob.capabilities.bank import Account
from weboob.tools.capabilities.bank.transactions import FrenchTransaction
......@@ -47,8 +47,12 @@ class SogeLoggedPage(object):
class AccountsPage(SogeLoggedPage, HTMLPage):
@pagination
@method
class iter_accounts(ListElement):
item_xpath = '//table//table[1]//tr'
class iter_accounts(TableElement):
item_xpath = '//table[@bgcolor="#92ADC2"]//tr'
head_xpath = '//table[@bgcolor="#92ADC2"]/tr[1]/td[text()]'
col_id = 'card iconetriwbeb(2);'
col_label = 'name iconetriwbeb(1);'
def next_page(self):
array_page = self.page.doc.xpath('//table[3]')[0]
......@@ -61,16 +65,16 @@ class AccountsPage(SogeLoggedPage, HTMLPage):
class item(ItemElement):
klass = Account
obj_id = CleanText('./td[6]', replace=[(' ', ''), ('X','')])
obj_label = CleanText('./td[5]')
obj_id = CleanText(TableCell('id'), replace=[(' ', ''), ('X','')])
obj_label = CleanText(TableCell('label'))
obj_type = Account.TYPE_CARD
@property
def obj__url(self):
a = self.el.xpath('./td[11]/a')
if a:
a = self.el.xpath('.//a')
if a and len(a) > 1:
#handling relative path
return '%s/%s' % ('/'.join(self.page.url.split('/')[:-1]), a[0].attrib['href'][2:])
return '%s/%s' % ('/'.join(self.page.url.split('/')[:-1]), a[-1].attrib['href'][2:])
return None
def condition(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment