Skip to content

Instantly share code, notes, and snippets.

@Tiposbingo
Last active July 17, 2018 09:53
Show Gist options
  • Save Tiposbingo/88a1add6e08feeee6a68b766d9eca048 to your computer and use it in GitHub Desktop.
Save Tiposbingo/88a1add6e08feeee6a68b766d9eca048 to your computer and use it in GitHub Desktop.
Really simple wordpress URL checker based on Python. Just add URL to URLS array and then use terminal "python wordpress-check.py"
#! /usr/bin/python
###############################################################################
#
# Lexo - version 0.000001 :D
#
###############################################################################
import time
import requests
URLS = [
'http://zzzamocnictvo.sk',
'http://zzzstudio.sk',
'http://zzzuby.sk',
]
GREEN = '\033[92m'
YELLOW = '\033[93m'
RED = '\033[91m'
ENDC = '\033[0m'
def main():
while True:
print "\nTesting URLs.", time.ctime()
checkUrls()
print "Press CTRL+C to exit"
time.sleep(10) #Sleep 10 seconds
def checkUrls():
for url in URLS:
status = "N/A"
hovno = "N/A"
kok2 = "/license.txt"
url = url+kok2
try:
status = checkUrl(url)
hovno = checkWor(url)
except requests.exceptions.ConnectionError:
status = "DOWN"
except requests.exceptions.Timeout:
print "Timeout occurred"
except requests.exceptions.TooManyRedirects:
print "TooManyRedirects"
except requests.exceptions.HTTPError as err:
print "HTTP ERROR" + err
except requests.exceptions.RequestException:
print "FUCK YOU"
except requests.exceptions.RequestException as e:
print e
printStatus(url, status, hovno)
def checkUrl(url):
r = requests.get(url, timeout=5)
return str(r.status_code)
def checkWor(url):
r = requests.get(url, timeout=5)
if 'WordPress' in r.text:
return True
def printStatus(url, status, hovno):
color = GREEN
if status != "200":
color=RED
if hovno == True:
hovno="WordPress"
else:
hovno = "-"
file_object = color+status+ENDC+' '+ url +' '+ hovno
wordpress_object = url + '\n'
print file_object
if hovno == "WordPress":
File=open("output.txt","a+")
File.write(wordpress_object)
File.close()
#
# Main app
#
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment