VOOZH about

URL: https://www.geeksforgeeks.org/python/test-the-given-page-is-found-or-not-on-the-server-using-python/

⇱ Test the given page is found or not on the server Using Python - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Test the given page is found or not on the server Using Python

Last Updated : 23 Jul, 2025

In this article, we are going to write a Python script to test the given page is found or not on the server. We will see various methods to do the same.

Method 1: Using Urllib.

Urllib is a package that allows you to access the webpage with the program.

Installation:

pip install urllib

Approach:

  • Import module
  • Pass the URL in urllib.request() reading URLs
  • Now check with urllib.error containing the exceptions raised by urllib.request

Implementation:

Output:

Yeah ! found

Method 2: Using requests

Request allows you to send HTTP/1.1 requests extremely easily. This module also does not come built-in with Python. To install this type the below command in the terminal.

Installation:

pip install requests

Approach:

  • Import module
  • Pass the Url into requests.head()
  • If response.status_code == 200 then server is up
  • if response.status_code == 404 then server in down

Implementation:

Output:

True
Comment