From f8c76b90a414d7edf6368ef2f7dba4dc5031d199 Mon Sep 17 00:00:00 2001 From: Crinibus <57172157+Crinibus@users.noreply.github.com> Date: Thu, 27 Oct 2022 22:56:32 +0200 Subject: [PATCH] Fix getting price and currency in HiFiKlubbenHandler --- scraper/domains.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scraper/domains.py b/scraper/domains.py index b867d933..44910d40 100644 --- a/scraper/domains.py +++ b/scraper/domains.py @@ -437,16 +437,20 @@ def get_short_url(self) -> str: class HifiKlubbenHandler(BaseWebsiteHandler): + def _get_common_data(self): + script_data_raw = self.request_data.findAll("script", type="application/ld+json")[1].text + self.product_data = json.loads(script_data_raw)["offers"] + def _get_product_name(self) -> str: brand_name = self.request_data.find("span", class_="product-page__brand-name").text model_name = self.request_data.find("span", class_="product-page__model-name").text return f"{brand_name} {model_name}" def _get_product_price(self) -> float: - return float(self.request_data.find("meta", itemprop="price").get("content")) + return float(self.product_data.get("price")) def _get_product_currency(self) -> str: - return self.request_data.find("meta", itemprop="priceCurrency").get("content") + return self.product_data.get("priceCurrency") def _get_product_id(self) -> str: return self.url.split("/")[4]