Don't Let Downtime Get You Down: Test Your Website with Python!

Check if site is down use case.


There is a nice online web service "Is It Down Right Now" that monitors the status of our favorite web sites and checks whether they are reachable or not.

Normally user enters the url and a fresh site status test will be performed on the domain name in real time using online website checker tool. More detailed information also available like check response time graph and user comments.

Website is it down test.
Test Your Website with Python meme.

Python Knowledge Base: Make coding great again.
- Updated: 2024-11-20 by Andrey BRATUS, Senior Data Analyst.




This Python test script below will use information from "Is It Down Right Now" and present it in text form without the need to use a web browser.
The program will form GET request with website address that you enter and will read response and prints out reachability status and details.



Python code to test if website is down:



import re
import requests


website = 'python-code.pro'


    
isitdown_url = f'https://www.isitdownrightnow.com/check.php?domain={website}'

r = requests.get(isitdown_url)

r_text = (r
          .text
          .lower()
          )

status = (re
          .compile(f'{domain} is (.*) (?:it is not|and reachable)') 
          .search(r_text)
          .group(1)
          .split(' ')
          [0]
          )

print(f'The website status is: {status}')
print(f'\n Additional information: {r_text}')

is site reachable.





See also related topics: