From cd9962231db7f12808c346cf5e702a2c6dc0a5bc Mon Sep 17 00:00:00 2001 From: Quentin Defenouillere Date: Fri, 15 Jan 2021 15:32:54 +0100 Subject: [PATCH] [boursorama] Correct investment labels & codes For the labels, we are fetching an tag, except that some invests have no link so we were retrieving invests with empty labels. We now handle or cases with a Coalesce. Codes were handled with IsinCode & code_types with IsinType. Used Base filter instead of ugly filter()(self)[0].xpath(). --- modules/boursorama/pages.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/boursorama/pages.py b/modules/boursorama/pages.py index df353d7a8d..04abbc17e1 100644 --- a/modules/boursorama/pages.py +++ b/modules/boursorama/pages.py @@ -853,17 +853,18 @@ class Myiter_investment(TableElement): class Myitem(ItemElement): klass = Investment + obj_label = Coalesce( + Base(TableCell('value'), CleanText('.//a')), + Base(TableCell('value'), CleanText('./strong')), # for investments without link + default='' + ) obj_quantity = CleanDecimal(TableCell('quantity'), default=NotAvailable) obj_unitprice = CleanDecimal(TableCell('unitprice'), replace_dots=True, default=NotAvailable) obj_unitvalue = CleanDecimal(TableCell('unitvalue'), replace_dots=True, default=NotAvailable) obj_valuation = CleanDecimal(TableCell('valuation'), replace_dots=True, default=NotAvailable) obj_diff = CleanDecimal(TableCell('diff'), replace_dots=True, default=NotAvailable) - - def obj_label(self): - return CleanText().filter((TableCell('value')(self)[0]).xpath('.//a')) - - def obj_code(self): - return CleanText().filter((TableCell('value')(self)[0]).xpath('./span')) or NotAvailable + obj_code = IsinCode(Base(TableCell('value'), CleanText('./span')), default=NotAvailable) + obj_code_type = IsinType(Base(TableCell('value'), CleanText('./span'))) def my_pagination(func): -- GitLab