In this article, we are going to learn how to check whether any website is running or it’s down with a simple Python script. We will use Python’s requests library for sending ‘get’ request and ‘smtplib’ library for sending email notification when the website is up.It means we don’t need to check every time. Our Python program will notify us via email when the site is running.
This script simply checks whether a website is up or not. If it is up then it will send an email about this, if it is down then it will keep checking and when the site will be up, it will send an email and terminate.
Go to command prompt and write this command:
pip install requests, smtplib
Below are the steps:
- Put the entire code into a try block, to handle the exception.
- Send a get request to the website we want.
- If website is not running, then we don’t get a response thus throwing an exception.
- Then in except block we just print that website is not running.
- If there is no exception thrown, then it means we got the response and website is running.
- Now Create SMTP session for login through gmail.
- Enter your correct gmail id and password.
- Send the mail and done.
Below is the implementation:
- How to send SMS alert using Python and MSG91 API
- Website Blocker Using Python
- Python | Parse a website with regex and urllib
- Python program to Recursively scrape all the URLs of the website
- Send PDF File through Email using pdf-mail module
- How to get synonyms/antonyms from NLTK WordNet in Python?
- Python | Program to crawl a web page and get most frequent words
- Python | Get a google map image of specified location using Google Static Maps API
- Python | Get the real time currency exchange rate
- Get Phone Number Information using Python
- Python - Get Hardware and System information using platform module
- Get Browser History using Python in Ubuntu
- Python - Get file id of windows file
- Python - Get list of running processes
- Get Your System Information - Using Python Script
- How to get COVID 19 update using Covid module in Python?
- Python script to get device vendor name from MAC Address
- Get Live Weather Desktop Notifications Using Python
- Python - Get Today's Current Day using Speech Recognition
- Python | Add Logging to a Python Script
Improved By : gjaiswal108