def load_price_currency_from_str(self, text): try: (price, currency) = parse_price_currency(text, self.context) self.add_value(F_PRICE, price) except Exception as e: self.add_value(F_PRICE, MISSING_VALUE) raise_missing_value(spider_name=self.context['spider_name'], field_name=F_PRICE, url=self.context[F_URL], exception=e, level=STATUS_CRITICAL, message="Could not load price and currency.", category=PARSING_ERROR)
def load_price_currency_from_str(self, text): try: (price, currency) = parse_price_currency(text, self.context) self.add_value(F_PRICE, price) except Exception as e: self.add_value(F_PRICE, MISSING_VALUE) raise_missing_value( spider_name=self.context['spider_name'], field_name=F_PRICE, url=self.context[F_URL], exception=e, level=STATUS_CRITICAL, message="Could not load price and currency.", category=PARSING_ERROR )
def load_price_currency(self, xpath, spider_name=''): try: text = ' '.join(self.selector.xpath(xpath).extract()) (price, currency) = parse_price_currency(text, self.context) self.add_value(F_PRICE, price) self.add_value(F_CURRENCY, currency) except Exception as e: self.add_value(F_PRICE, MISSING_VALUE) site = SITE_MODEL.objects.get(spider_name=spider_name) self.add_value(F_CURRENCY, site.country.currency) raise_missing_value(spider_name=self.context['spider_name'], field_name=F_PRICE, url=self.context[F_URL], exception=e, level=STATUS_CRITICAL, message="Could not load price and currency.", category=PARSING_ERROR)
def load_price_currency(self, xpath, spider_name=''): try: text = ' '.join(self.selector.xpath(xpath).extract()) (price, currency) = parse_price_currency(text, self.context) self.add_value(F_PRICE, price) self.add_value(F_CURRENCY, currency) except Exception as e: self.add_value(F_PRICE, MISSING_VALUE) site = SITE_MODEL.objects.get(spider_name=spider_name) self.add_value(F_CURRENCY, site.country.currency) raise_missing_value( spider_name=self.context['spider_name'], field_name=F_PRICE, url=self.context[F_URL], exception=e, level=STATUS_CRITICAL, message="Could not load price and currency.", category=PARSING_ERROR )