This is a simple selenium-based stock checker made with Python, that checks if a product is on stock on a specified platform.
There is 7 different steps(TODOs) you have to follow in order for the script to function properly after your needs.
- Make a copy of the
.env.exampleso it becomes.envand fill in the values. - Insert product specific information. This includes both a name and link for the product.
- Insert how often a lookup should be performed by the script. This value should be in seconds.
- Fill in the what the script should look after (Find a product that is not in stock on the platform and add the description under the error_msg. Do the opposite and add the description to success_msg).
- If you want to have email validations in order to assure the script is running, you can enable email validations by changing the value for the
choicefield toTrue. (This is on by default) - If you want to add CC recipients so multiple users can get notified by email, this can be done here. Remember to seperate e-mails by a comma.
- If you want to setup discord announcements, a Discord Webhook URL has to be added inside the
.envfile, and the value for thediscord_announcementfield shoud be changed toTrue. (This is False by default)
Run
> pip install -r requirements.txtChromedriver can be installed in two ways.
- By downloading it from the website and the specifying the path to the driver.
- By using Service that comes with the ChromeDriver library and then specifying which driver manager that should be used so it can be downloaded automatically.
# Automatic installation
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
# Manual installation 1/2
> sudo apt-get install chromium-chromedriver
# Now insert the path for the chromedriver 2/2
driver = webdriver.Chrome('usr/bin/chromedriver') By default the script is being run in a headless manner, meaning the chrome GUI won't be shown. In short terms, the script is completely running in the background.
# Chrome Driver options
chrome_options = Options()
chrome_options.add_argument("--headless") # Comment out if you want to have the GUIYou can upload the bot to different cloud service providers by following their deployment methods.
BUT, keep in mind that:
- Linode blocks SMTP ports
- Rasperry Pi's uses ARM, and that can be a pain in the ass when using the chromedriver. (There is a chromedriver for ARM though, but again it can get quite annoying.)
- Amazon EC2 instances should be fine, but for some reason i could not make it to work properly.
- Hosting it yourself. But its not optimal, so you have to do a little research yourself!