Skip to content

Instantly share code, notes, and snippets.

@megamaz
Last active July 26, 2019 16:28
Show Gist options
  • Save megamaz/54ea880af345177544a9fa8914a57635 to your computer and use it in GitHub Desktop.
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)
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