Skip to content
Open
Show file tree
Hide file tree
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
31 changes: 27 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import random

import schedule
from win10toast import ToastNotifier
import requests
import time

from bs4 import BeautifulSoup
from win10toast import ToastNotifier
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the duplicate import


#creating the Toaster object to handle notifications
toaster = ToastNotifier()

# toaster.show_toast("Sample Notification","Python is awesome!!!")
amazon_urls = ["https://www.amazon.in/Xbox-Series-X/dp/B08J7QX1N1"]
flipkart_urls = ["https://www.flipkart.com/microsoft-xbox-series-x-1024-gb/p/itm63ff9bd504f27"]
reliance_url = ["https://www.reliancedigital.in/xbox-series-x-console-with-wireless-controller-1-tb/p/491934660"]
Expand Down Expand Up @@ -32,46 +40,61 @@ def check_amazon(url):
soup = getSoup(url)
div_data = list(soup.find_all("input", id="add-to-cart-button"))
if div_data:
toaster.show_toast("Found Stock on Amazon: ", icon_path="xb.ico" + url)
print("Found stock on amazon: " + url)
return True
else:
toaster.show_toast("No Stock Found on Amazon...!", icon_path="xb.ico")
return False


def check_flipkart(url):
soup = getSoup(url)
button_data = list(soup.find_all("button", class_="_2KpZ6l _2U9uOA ihZ75k _3AWRsL"))
if button_data:
toaster.show_toast("Found Stock on flipkart: ", icon_path="xb.ico" + url)
print("Found stock on flipkart: " + url)
return True
else:
toaster.show_toast("No Stock Found on flipkart...!", icon_path="xb.ico")
return False


def check_reliance(url):
soup = getSoup(url)
button_list = list(soup.find_all("button", id="add_to_cart_main_btn"))
if button_list:
toaster.show_toast("Found stock on RD: "+url)
print("Found stock on RD : " + url)
return True
else:
toaster.show_toast("No Stock Found on Reliance...!", icon_path="xb.ico")
return False


def check_vijaySales(url):
soup = getSoup(url)
button_list = list(soup.find_all("div", attrs={"class":"btnsCartBuy", "style":"display:block"}))
if button_list:
toaster.show_toast("Found Stock on Vijay Sales: ", icon_path="xb.ico"+url)
print("Found stock on Vijay Sales : " + url)
return True
else:
toaster.show_toast("No Stock Found on Vijay Sales...!", icon_path="xb.ico",)
return False


if __name__ == '__main__':
def main():
toaster.show_toast("Searching for Xbox Series X in India...", icon_path="xb.ico",)
create_header_list()
result_rd = [check_reliance(url) for url in reliance_url]
result_amazon = [check_amazon(url) for url in amazon_urls]
result_flipkart = [check_flipkart(url) for url in flipkart_urls]
result_vijaySales = [check_vijaySales(url) for url in vs_urls]
print("The end..")
toaster.show_toast("The Next Search will begin in the next Six hours...", icon_path="xb.ico")


if __name__ == '__main__':
schedule.every(5).seconds.do(main)
while True:
schedule.run_pending()
time.sleep(1)
5 changes: 4 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
requests==2.22.0
beautifulsoup4~=4.9.3
beautifulsoup4~=4.9.3
win10toast
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Its always a good practice to have the version in the requirements, its possible libraries introduce breaking changes in newer versions which might break the application.
  2. win10toast is a windows binary, so I am not even able to run this code on a mac, you can add something like this win10toast==0.9; platform_system == "Windows", which would only install this on windows devices

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alright Got it

schedule==1.1.0
time
Binary file added xb.ico
Binary file not shown.