Last active
July 26, 2019 16:28
-
-
Save megamaz/54ea880af345177544a9fa8914a57635 to your computer and use it in GitHub Desktop.
Checks a website. I currently have no way of checking if the website exists, therefore please be sure that the website exists. Otherwise, it'll crash. (runtime error)
This file contains 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
import time, requests, sys | |
print("\n"*100) | |
url = str(input("INSERT URL HERE: ")) | |
if url[:8] != "https://": | |
if url[:7] != "http://": | |
print("not a url.") | |
sys.exit(0) | |
sys.exit(0) | |
while True: | |
check = requests.get(url) | |
if check.status_code != 200: | |
if check.status_code == 429: | |
print(f"Checking {url}: Not working. status: {check.status_code}") | |
print("status 429 requires longer wait.") | |
time.sleep(int((check.headers['retry-after']))) | |
sys.exit(0) | |
else: | |
print(f"Checking {url}: Not working. status: {check.status_code}") | |
time.sleep(2) | |
else: | |
print(f"Checking {url}: Working conditions. status: {check.status_code}") | |
time.sleep(2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment