From 64e92504e3a3aa62a3c9c0b17c608ed443d08623 Mon Sep 17 00:00:00 2001 From: Florent Viard Date: Wed, 28 Oct 2020 18:11:05 +0100 Subject: [PATCH] [boursorama] Fixes iter_recipients for recipients having a "-" in their labels --- modules/boursorama/pages.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/modules/boursorama/pages.py b/modules/boursorama/pages.py index 0b221d1561..06e4b16605 100644 --- a/modules/boursorama/pages.py +++ b/modules/boursorama/pages.py @@ -1333,15 +1333,22 @@ class item(ItemElement): klass = Recipient obj_id = CleanText( - './/span[contains(@class, "sub-label")]/span[not(contains(@class,"sub-label"))]', + './/span[contains(@class, "account-sub-label")]/span[not(contains(@class,"account-before-sub-label"))]', replace=[(' ', '')], ) - obj_label = CleanText(Regexp( - CleanText('.//span[contains(@class, "account-label")]'), - r'([^-]+)', - '\\1', - )) + # bank name finish with the following text " •" + obj_bank_name = CleanText('.//span[contains(@class, "account-before-sub-label")]', symbols=['•']) + + def obj_label(self): + bank_name = Field('bank_name')(self) + label = CleanText('.//span[contains(@class, "account-label")]')(self) + + # Sometimes, Boursorama appends the bank name at the end of the label + if not empty(bank_name): + label = label.replace('- %s' % bank_name, '').strip() + + return label def obj_category(self): text = CleanText( -- GitLab