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

2

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

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs