Skip to content

Commit

Permalink
Fixed Amazon price/stock not being scraped
Browse files Browse the repository at this point in the history
  • Loading branch information
shahrk committed Nov 21, 2021
1 parent e237d4a commit 4c53652
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
11 changes: 4 additions & 7 deletions code/AmazonScraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,15 @@ def check_stock_price(self, url):
sub_class_stock = soup.find("div", {"id": "availability"})
# finding the div containing out of stock info
sub_class_no_stock = soup.find("div", {"id": "outOfStock"})

cost = soup.find("span", {"id": "priceblock_ourprice"})
cost = soup.find_all('span', {'class' : 'a-price'})[0].contents[0].contents[0]
# price = re.match("\$(\d*,)*\d*\.\d*", cost)
cost = cost.contents[0]
# cost = cost.contents[0]
# print(cost)

if sub_class_stock and not sub_class_no_stock:
if "order soon" in str(sub_class_stock):
if "success" in str(sub_class_stock) or "order soon" in str(sub_class_stock):
return "In Stock", cost
elif "In stock soon" in str(sub_class_stock):
return "Out of Stock", "NA"
return "In Stock", cost
return "Out of Stock", "NA"
elif sub_class_no_stock:
return "Out of Stock", "NA"
# This handles the case of having no stock info on the page/captcha page
Expand Down
10 changes: 5 additions & 5 deletions code/GUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,11 @@ def run_timer(self):
self.update_stock_info(
entry, item_name, item_url, item_stock, item_cost
)
if item_stock == "In Stock" and item_pstock != "In Stock":
app.update()
self.items_list.alert(item_name, item_url)
self.interval_entry.focus_force()
self.email_addr_entry.focus_force()
# if item_stock == "In Stock" and item_pstock != "In Stock":
# app.update()
# self.items_list.alert(item_name, item_url)
# self.interval_entry.focus_force()
# self.email_addr_entry.focus_force()

self.after(1000, self.run_timer)

Expand Down

0 comments on commit 4c53652

Please sign in to comment.