a little helper if you are reporting / tracking the registrar/host actions of a list of websites.
copy/paste the list (1 URL per line) to the script (e.g. from a spreadsheet), hit enter, the script will check each sites status and give you a list.
Remark: not 100% accurate (for example: some registrars create a placeholder page if they suspended a domain which could be falsely marked as “up”). Probably some more flaws but a good time saver.
import requests
import random
import time
import os
script_name = os.path.splitext(os.path.basename(__file__))[0] # Get script name without extension
output_file = f"{script_name}.txt" # Save results as "07_websitchecker.txt"
# List of common User-Agent strings
user_agents = [
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36",
"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:42.0) Gecko/20100101 Firefox/42.0",
"Mozilla/5.0 (Linux; Android 10; SM-G960F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Mobile Safari/537.36",
"Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0",
"Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0",
"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:40.0) Gecko/20100101 Firefox/40.0",
"Mozilla/5.0 (Windows NT 6.1; Trident/7.0; AS; ASBXJS; en-US) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1941.0 Safari/537.36 Edge/12.0"
]
def check_website(url):
try:
headers = {'User-Agent': random.choice(user_agents)}
response = requests.get(url, timeout=10, allow_redirects=True, headers=headers)
final_url = response.url
if "cgi-sys/suspendedpage.cgi" in final_url:
return "down"
if response.status_code == 403:
page_content = response.text.lower()
cloudflare_keywords = ["deceptive site ahead", "phishing", "suspicious site", "cloudflare"]
if any(keyword in page_content for keyword in cloudflare_keywords):
return "phishing"
else:
return "down"
if response.status_code == 503:
return "down"
if "Error code 525" in response.text:
return "down"
return "up"
except requests.exceptions.SSLError as e:
if "525" in str(e):
return "down"
return "ssl_error"
except requests.exceptions.ConnectionError as e:
if "Failed to resolve" in str(e) or "[Errno 11001]" in str(e) or "[Errno 11002]" in str(e):
return "down"
return "error"
except requests.exceptions.Timeout:
return "timeout"
except Exception:
return "error"
# Get user input
print("Paste the list of websites you want to check, one per line. Press Enter on an empty line when done:")
urls = []
while True:
line = input().strip()
if not line:
break
urls.append(line)
# Open file for writing and initialize results
with open(output_file, "w", encoding="utf-8") as file:
pass # Create/Clear file at start
down_sites = []
for i, url in enumerate(urls):
status = check_website(url)
result = f"{url} {status}\n"
print(result.strip())
# Append to output file
with open(output_file, "a", encoding="utf-8") as file:
file.write(result)
if status == "down":
down_sites.append(url)
if i < len(urls) - 1:
wait_time = random.randint(25, 35)
print(f"Waiting {wait_time} seconds before next request...\n")
time.sleep(wait_time)
# Add summary of down websites
summary = "\nDown sites:\n"
if down_sites:
summary += "\n".join(down_sites)
else:
summary += "-"
print(summary)
with open(output_file, "a", encoding="utf-8") as file:
file.write(summary)
print(f"\nFinished checking all websites. Results saved to {output_file}")
# Keep CMD window open
input("\nPress Enter to exit...")