import requests from bs4 import BeautifulSoup import smtplib URL = 'https://www.amazon.com.tr/G%C3%9CRAL-PORSELEN-SA24Y49205411-24PAR%C3%87A-TAKIMI/dp/B08BKY5TBP/ref=sr_1_1?crid=18XMDLCR1FA4B&keywords=g%C3%BCral+porselen+bilbao+yemek+tak%C4%B1m%C4%B1&qid=1640905004&sprefix=g%C3%BCral+porselen+bilbao%2Caps%2C130&sr=8-1' headers = { "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"} def priceChecking(URL,maxPrice): page = requests.get(URL, headers=headers) soup = BeautifulSoup(page.content, 'html.parser') # title = soup.find(id="productTitle").getText().strip() price = soup.find(class_="a-offscreen").getText().strip() newPrice = float(price[0:-2].replace(",",".")) if(newPrice < maxPrice): send_email("bbaydn@gmail.com",URL) else: print("ürün fiyatı düşmedi") def send_email(toMail, url): server = smtplib.SMTP("smtp.gmail.com",587) server.ehlo() server.starttls() server.ehlo() server.login("bbaydn@gmail.com","rusywkngewcwqjoh") subject = "Fiyat düşüşü!" body = "Ürün linki: " + url msg = f"Subject: {subject}\n\n {body}" server.sendmail("bbaydn@gmail.com", "busraaydin397@gmail.com", msg ) print("Mesaj gönderildi.") server.quit() priceChecking(URL, 800)