Skip to content

Commit

Permalink
Merge pull request #190 from Crinibus/fix-hifiklubben-handler
Browse files Browse the repository at this point in the history
Fix getting price and currency in HiFiKlubbenHandler
  • Loading branch information
Crinibus authored Oct 27, 2022
2 parents 8e2a12e + f8c76b9 commit 0093244
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions scraper/domains.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 0093244

Please sign in to comment.