From 934bf41e49e0a3b3af29125959e5565b0d0e25ed Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Fri, 19 Jun 2015 17:25:31 +0200 Subject: [PATCH] fix new list of accounts and new URLs --- modules/hsbc/browser.py | 20 +++++++++++++------- modules/hsbc/pages.py | 28 +++++----------------------- 2 files changed, 18 insertions(+), 30 deletions(-) diff --git a/modules/hsbc/browser.py b/modules/hsbc/browser.py index 23dddc1c..e6c31183 100644 --- a/modules/hsbc/browser.py +++ b/modules/hsbc/browser.py @@ -36,10 +36,13 @@ class HSBC(LoginBrowser): connection = URL(r'https://www.hsbc.fr/1/2/hsbc-france/particuliers/connexion', LoginPage) login = URL(r'https://www.hsbc.fr/1/*', LoginPage) - cptPage = URL(r'/cgi-bin/emcgi.*\&CPT_IdPrestation.*', + cptPage = URL(r'/cgi-bin/emcgi.*\&Cpt=.*', + r'/cgi-bin/emcgi.*\&Epa=.*', + r'/cgi-bin/emcgi.*\&CPT_IdPrestation.*', r'/cgi-bin/emcgi.*\&Ass_IdPrestation.*', CPTOperationPage) - cbPage = URL(r'/cgi-bin/emcgi.*\&CB_IdPrestation.*', + cbPage = URL(r'/cgi-bin/emcgi.*\&Cb=.*', + r'/cgi-bin/emcgi.*\&CB_IdPrestation.*', CBOperationPage) appGone = URL(r'/.*_absente.html', r'/pm_absent_inter.html', @@ -51,6 +54,9 @@ class HSBC(LoginBrowser): self.secret = secret LoginBrowser.__init__(self, username, password, *args, **kwargs) + def load_state(self, state): + return + def prepare_request(self, req): preq = super(HSBC, self).prepare_request(req) @@ -59,11 +65,8 @@ class HSBC(LoginBrowser): return preq - def home(self): - return self.login.go() - def do_login(self): - self.connection.stay_or_go() + self.connection.go() self.page.login(self.username) no_secure_key_link = self.page.get_no_secure_key() @@ -95,9 +98,12 @@ class HSBC(LoginBrowser): @need_login def get_history(self, account): - if account._link_id is None: return + + if account._link_id.startswith('javascript'): + raise NotImplementedError() + self.location(self.accounts_list[account.id]._link_id) #If we relogin on hsbc, all link have change diff --git a/modules/hsbc/pages.py b/modules/hsbc/pages.py index bf0f744a..57b7bf29 100644 --- a/modules/hsbc/pages.py +++ b/modules/hsbc/pages.py @@ -72,33 +72,14 @@ class AccountsPage(LoggedPage, HTMLPage): def filter(self, label): return Account.TYPE_UNKNOWN - obj_id = Env('id') + obj_id = CleanText('./td[2]', replace=[('.', ''), (' ', '')]) obj_label = Label(CleanText('./td[1]/a')) obj_coming = Env('coming') - obj_balance = Env('balance') - obj_currency = FrenchTransaction.Currency('./td[2] | ./td[3]') + obj_balance = CleanDecimal('./td[3]', replace_dots=True) + obj_currency = FrenchTransaction.Currency('./td[3]') obj__link_id = Link('./td[1]/a') obj_type = Type(Field('label')) - - def parse(self, el): - link = el.xpath('./td[1]/a')[0].get('href', '') - url = urlparse(link) - p = parse_qs(url.query) - - if 'CPT_IdPrestation' in p: - id = p['CPT_IdPrestation'][0] - elif 'Ass_IdPrestation' in p: - id = p['Ass_IdPrestation'][0] - elif 'CB_IdPrestation' in p: - id = p['CB_IdPrestation'][0] - else: - raise SkipItem() - - balance = CleanDecimal('./td[3]', replace_dots=True)(self) - - self.env['id'] = id - self.env['balance'] = balance - self.env['coming'] = NotAvailable + obj_coming = NotAvailable class Pagination(object): @@ -147,6 +128,7 @@ class CPTOperationPage(LoggedPage, HTMLPage): class AppGonePage(HTMLPage): def on_load(self): self.browser.app_gone = True + self.logger.info('Application has gone. Relogging...') self.browser.do_logout() self.browser.do_login()