<gh_stars>0
import os
import smtplib
from dotenv import load_dotenv
from selenium import webdriver

load_dotenv()

MY_EMAIL = os.environ.get("MY_EMAIL")
MY_PASSWORD = os.environ.get("MY_PASSWORD")
TARGET_PRICE = 30.0

chrome_driver_path = "C:\Development\chromedriver_win32\chromedriver.exe"
options = webdriver.ChromeOptions()
options.add_experimental_option('excludeSwitches', ['enable-logging'])
driver = webdriver.Chrome(executable_path=chrome_driver_path, options=options)
driver.get("https://www.amazon.com/Mueller-Electric-SpeedBoil-Borosilicate-Protection/dp/B07TZ5YHJN/ref=sr_1_5?dchild=1&keywords=kettle&qid=1631233092&sr=8-5")

price = driver.find_element_by_id("priceblock_ourprice")
if float(price.text[1:]) <= TARGET_PRICE:
    connection = smtplib.SMTP("smtp.gmail.com", 587)
    connection.starttls()
    connection.login(MY_EMAIL, MY_PASSWORD)
    connection.sendmail(
        from_addr = MY_EMAIL,
        to_addrs = MY_EMAIL,
        msg = f"Subject:BUY NOW!\n\nThe object that you are looking for on Amazon has dropped its price below your target price of ${TARGET_PRICE}. Currently, it is sold for {price.text}."
    )
    print("Email sent!")
else:
    print("Waiting for the current price to dropped below target.")

driver.quit()

import os
import smtplib
from dotenv import load_dotenv
from selenium import webdriver

load_dotenv()

MY_EMAIL = os.environ.get("MY_EMAIL")
MY_PASSWORD = os.environ.get("MY_PASSWORD")
TARGET_PRICE = 30.0

chrome_driver_path = "C:\Development\chromedriver_win32\chromedriver.exe"
options = webdriver.ChromeOptions()
options.add_experimental_option('excludeSwitches', ['enable-logging'])
driver = webdriver.Chrome(executable_path=chrome_driver_path, options=options)
driver.get("https://www.amazon.com/Mueller-Electric-SpeedBoil-Borosilicate-Protection/dp/B07TZ5YHJN/ref=sr_1_5?dchild=1&keywords=kettle&qid=1631233092&sr=8-5")

price = driver.find_element_by_id("priceblock_ourprice")
if float(price.text[1:]) <= TARGET_PRICE:
    connection = smtplib.SMTP("smtp.gmail.com", 587)
    connection.starttls()
    connection.login(MY_EMAIL, MY_PASSWORD)
    connection.sendmail(
        from_addr = MY_EMAIL,
        to_addrs = MY_EMAIL,
        msg = f"Subject:BUY NOW!\n\nThe object that you are looking for on Amazon has dropped its price below your target price of ${TARGET_PRICE}. Currently, it is sold for {price.text}."
    )
    print("Email sent!")
else:
    print("Waiting for the current price to dropped below target.")

driver.quit()