Skip to content
Related Articles

Related Articles

Improve Article

An application to test the given page is found or not on the server using Python

  • Last Updated : 21 Jun, 2021

Prerequisite: Python Urllib module

In this article, we are going to write scripts to test whether the given page is found on the server or not with a GUI application. We need to Install Urllib Module to carry out this operation. Type this command in your terminal.

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

pip install urllib


  • Import urllib module.
  • Read URL with urllib.request.urlopen().
  • Check if Read URL gives any exception.



# import module
from urllib.request import urlopen, URLError, HTTPError
# exception handling to
# catch URL error
    html = urlopen("")
except URLError as e:
    print("Server not found!")
except HTTPError as e:
    print("HTTP error")
    print("Server found")


Server found

Application to test the given page is found or not on the server with Tkinter: This Script combines the implementation above with a GUI.


# import modules
from tkinter import *
from urllib.request import urlopen, URLError
# user defined function
def URL_check():
        html = urlopen(str(e1.get()))
    except URLError as e:
        res = "Server not found!"
        res = "Server found"
# object of tkinter
# and background set to light grey
master = Tk()
master.configure(bg='light grey')
# Variable Classes in tkinter
result = StringVar()
# Creating label for each information
# name using widget Label
Label(master, text="Enter URL : ", bg="light grey").grid(row=1, sticky=W)
Label(master, text="Status :", bg="light grey").grid(row=3, sticky=W)
# Creating lebel for class variable
# name using widget Entry
Label(master, text="", textvariable=result,
      bg="light grey").grid(row=3, column=1, sticky=W)
e1 = Entry(master, width=50)
e1.grid(row=1, column=1)
# creating a button using the widget
b = Button(master, text="Check", command=URL_check, bg="white")
b.grid(row=1, column=2, columnspan=2, rowspan=2, padx=5, pady=5,)


Check another URL.

My Personal Notes arrow_drop_up
Recommended Articles
Page :