-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsite_upchecker_mini.py
41 lines (31 loc) · 1.33 KB
/
site_upchecker_mini.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# this check if site is up or down for every 300 secs or 5 mind
# and in the end it'll pop a new windows if the site is up
import requests # pip install requests
import time
from tkinter import messagebox
# import winsound # pip install winaudio || uncomment for a beep and this works only on windows
def check_site(url):
try:
response = requests.get(url)
if response.status_code == 200:
return True
else:
return False
except requests.exceptions.RequestException as e:
print(f"Error: {e}")
return False
def main():
site_url = input("Enter the site URL (google.com) : ")
site_url = 'https://' + site_url #if not site_url.startswith("http") # or url.startswith("http") else url
while True:
if check_site(site_url):
print(f"{site_url} is up.")
# winsound.Beep(500, 5000) # uncomment for a beep and this works only on windows
messagebox.showwarning("Sucess", f"The site {site_url} is back online.")
# winsound.PlaySound("path/to/custom_sound.wav", winsound.SND_FILENAME) # if you want a custom music
return
else:
print(f"{site_url} is down.")
time.sleep(300) # Check every 300 seconds
if __name__ == "__main__":
main()