Created
June 1, 2017 08:13
-
-
Save dicksonkv/6863b3811ca2949a82f363d40adffddb to your computer and use it in GitHub Desktop.
Python Script to check Site Status
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import json | |
import requests | |
import os | |
import sys | |
from termcolor import colored | |
SITE_JSON_FILE = './site.json' | |
if os.path.exists(SITE_JSON_FILE): | |
try: | |
scanDB = json.loads( open(SITE_JSON_FILE,'r').read() ) | |
for siteName in scanDB: | |
print( '{:<16}{:30}'.format( ' [ Checking ] :',siteName),end='') | |
try: | |
response = requests.get(siteName) | |
if response.status_code == 200: | |
print('[ ',colored('up', 'green'), ' ]') | |
else: | |
print('[ ',colored('down', 'red'), ' ]') | |
except: | |
print('[ Unable To Process Request.]') | |
except: | |
print('') | |
print('Unable To Read Data From',SITE_JSON_FILE) | |
print('') | |
sys.exit(1) | |
else: | |
print('') | |
print('File Not Found :',SITE_JSON_FILE) | |
print('') | |
sys.exit(1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"https://apache.org/":"Apache Software Foundation.", | |
"https://www.gnu.org/":"Gnu Is Not Unix", | |
"https://www.freebsd.org/":"FreeBsd It", | |
"https://www.centos.org/":"CentoS web site", | |
"https://www.irctc.co.in":"ellatha site" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment