Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format with black #189

Merged
merged 1 commit into from
Oct 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions scraper/domains.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ def _get_product_price(self) -> float:
try:
# find normal price
price = float(
self.request_data.find("span", class_="site-currency-attention").text.replace(".", "").replace(",", ".").strip(" kr")
self.request_data.find("span", class_="site-currency-attention")
.text.replace(".", "")
.replace(",", ".")
.strip(" kr")
)
except AttributeError:
try:
Expand All @@ -116,7 +119,10 @@ def _get_product_price(self) -> float:
except AttributeError:
# if campaign is sold out (udsolgt)
price = float(
self.request_data.find("div", class_="site-currency-attention").text.replace(".", "").replace(",", ".").strip(" kr")
self.request_data.find("div", class_="site-currency-attention")
.text.replace(".", "")
.replace(",", ".")
.strip(" kr")
)
return price

Expand Down Expand Up @@ -232,13 +238,17 @@ def _get_product_price(self) -> float:
try:
return float(self.request_data.find("input", id="attach-base-product-price").get("value"))
except (AttributeError, ValueError, TypeError):
return float(self.request_data.find("span", class_="a-price a-text-price a-size-medium").span.text.replace("$", ""))
return float(
self.request_data.find("span", class_="a-price a-text-price a-size-medium").span.text.replace("$", "")
)

def _get_product_currency(self) -> str:
try:
return self.request_data.find("input", id="attach-currency-of-preference").get("value")
except (AttributeError, ValueError, TypeError):
return self.request_data.find("a", id="icp-touch-link-cop").find("span", class_="icp-color-base").text.split(" ")[0]
return (
self.request_data.find("a", id="icp-touch-link-cop").find("span", class_="icp-color-base").text.split(" ")[0]
)

def _get_product_id(self) -> str:
try:
Expand All @@ -265,7 +275,12 @@ def _get_product_price(self) -> float:
if self.soup_url.split("/")[3] == "itm":
price = float(self.request_data.find("span", itemprop="price").get("content"))
else:
price = float(self.request_data.find("div", class_="display-price").text.replace("DKK ", "").replace("$", "").replace(",", ""))
price = float(
self.request_data.find("div", class_="display-price")
.text.replace("DKK ", "")
.replace("$", "")
.replace(",", "")
)

return price

Expand Down