import requests import smtplib import json import time import schedule def price(): url = "https://api.coingecko.com/api/v3/coins/markets" params = { 'vs_currency': 'USD', 'order': 'market_cap_desc', 'per_page': 100, 'page': 1, 'sparkline': False } response = requests.get(url, params=params) data = response.json() btc_price = data[0]['current_price'] return btc_price def email(btc): sender_email = "your mail address" sender_password = "password" receiver_email = "receiving email" subject = "BTC Price Alert" body = f"The current price of BTC is {btc} USD. Time to make a move!" message = f"Subject: {subject}\n\n{body}" # change the mail.pissmail.com to the email provider you use with smtplib.SMTP("mail.pissmail.com", 587) as server: server.starttls() server.login(sender_email, sender_password) server.sendmail(sender_email, receiver_email, message) def check(): btc_price = price() alert = input("enter the alert number you want: ") print(alert) if btc_price == alert: email(btc_price) print(f"Alert! BTC price is {btc_price} USD. Email sent.") schedule.every().hour.do(check) while True: schedule.run_pending() time.sleep(1)