def __deal_with_rank(self, ranks: list): splits = self.site_config.product_rank_split replace = self.site_config.product_rank_replace if type(splits) == str: splits = [splits] rs = dict() for rank in ranks: for split in splits: item = rank.split(split) if len(item) == 2: rank_num = str2int(replace_multi(item[0], replace, '')) if rank_num: rs[item[1].replace('(', '').replace(')', '').strip()] = rank_num break return rs
def __deal_with_rating(self, rating): rating = replace_multi(rating, self.site_config.product_rating_split, '').strip() return str2float(rating, 1)
def __deal_with_helpers(elements: list): if not elements: return 0 helper_str = replace_multi(''.join(elements).strip(), [",", "."], '').split(' ')[0] return str2int(helper_str, 1)
def get_element_price(self) -> str: elements = self.html.xpath(self.site_config.product_price_xpath) return replace_multi( ''.join(elements).strip(), [' ', ' ', self.site_config.product_price_unit], '')