DEV Community

Cover image for Day 9 - Check a site is up or not - 100 days 100 python scripts
Ganesh Raja
Ganesh Raja

Posted on

Day 9 - Check a site is up or not - 100 days 100 python scripts

Day 9: check_site_live

This script checks if a site is active or not in the given intervals. if it's down it sends a notification.

import requests,os,time

SITE_URL=""
SLEEP_SEC=300 #5 mins
while True:
    response=requests.get(SITE_URL)
    print(response)
    if response.status_code!=200:
          os.system('notify-send "Website Down" "'+SITE_URL+'is down"')
          break
    time.sleep(SLEEP_SEC)
Enter fullscreen mode Exit fullscreen mode

Please Visit my Git Repo to check out all the previous day challenges.

https://github.com/ganeshraja10/automated-python-scripts

Top comments (0)