Friday, October 17, 2025
HomeLanguagesAn application to test the given page is found or not on...

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

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.

pip install urllib

Approach:

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

Implementation:

Python3




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


Output:

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.

Python3




# import modules
from tkinter import *
from urllib.request import urlopen, URLError
 
# user defined function
def URL_check():
    try:
        html = urlopen(str(e1.get()))
    except URLError as e:
        res = "Server not found!"
    else:
        res = "Server found"
    result.set(res)
 
 
# 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 label 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,)
 
mainloop()


Output:

Check another URL.

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS