Skip to content

Commit daf53cd

Browse files
fiott248t2013anurag
authored andcommitted
Created a python script that checks if website is online or if website have any redirects (hacktoberfest17#1662)
* fiott248_check_website_status_python.py simple script that checks the http request like 404, 301 and off course 200 * fiott248_check_website_status_python.py simple script that checks the http request like 404, 301 and off course 200 * duplicate file deleting duplicate file * adding a readme file * Update readme.md * fiott248_check_website_Status_python.py
1 parent 0a69e6d commit daf53cd

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import urllib2
2+
import socket
3+
4+
def check_url( url, timeout=10 ):
5+
httpcode =1
6+
if urllib2.urlopen(url,timeout=timeout).getcode() == 200:
7+
return "website is online"
8+
elif urllib2.urlopen(url,timeout=timeout).getcode() == 301:
9+
return "website was redirected permaanently"
10+
elif urllib2.urlopen(url,timeout=timeout).getcode() == 404:
11+
return "website was not found"
12+
print "please enter a website to check the status. don`t forget to add the http://"
13+
site = raw_input()
14+
print check_url(site)

check_website_status/readme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<h1> This is a simple Script that checks the http request code for the link you give the program </h1>
2+
3+
this script was written with python.
4+
5+
this script checks for 200 ,301 and 404 to defines whats happening the link that was given.

0 commit comments

Comments
 (0)