Skip to content

Commit

Permalink
Merge pull request #205 from Crinibus/fix-get-amazon-price
Browse files Browse the repository at this point in the history
Fix getting Amazon price
  • Loading branch information
Crinibus authored Dec 5, 2022
2 parents fe12ce7 + a587b5b commit 3d1d537
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
7 changes: 1 addition & 6 deletions scraper/domains.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,7 @@ def _get_product_name(self) -> str:
return self.request_data.find("span", id="productTitle").text.strip()

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").span.text.replace("$", ""))

def _get_product_currency(self) -> str:
try:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_objects.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
"expected_currency": "DKK"
},
"amazon": {
"link": "https://www.amazon.com/Sony-WH-1000XM4-Canceling-Headphones-Phone-Call/dp/B092LHZWXN/ref=pd_rhf_d_ee_s_pd_sbs_rvi_sccl_1_2/146-2828110-0046747?pd_rd_w=yk0z7&content-id=amzn1.sym.a089f039-4dde-401a-9041-8b534ae99e65&pf_rd_p=a089f039-4dde-401a-9041-8b534ae99e65&pf_rd_r=RZA04PRQVA24GDBD686T&pd_rd_wg=lEmqI&pd_rd_r=0834962e-faa2-4f42-82b8-8a2b55abf6b2&pd_rd_i=B092LHZWXN&psc=1",
"expected_title": "Sony WH-1000XM4 Wireless Premium Noise Canceling Overhead Headphones, Blue (Renewed)",
"expected_id": "B092LHZWXN",
"link": "https://www.amazon.com/Sony-WH-1000XM5-Canceling-Headphones-Hands-Free/dp/B09XS7JWHH",
"expected_title": "Sony WH-1000XM5 Wireless Industry Leading Noise Canceling Headphones with Auto Noise Canceling Optimizer, Crystal Clear Hands-Free Calling, and Alexa Voice Control, Black",
"expected_id": "B09XS7JWHH",
"expected_currency": "USD"
},
"ebay_with_itm": {
Expand Down

0 comments on commit 3d1d537

Please sign in to comment.