bswen / bswen-project

code for www.bswen.com
http://www.bswen.com
Apache License 2.0
20 stars 34 forks source link

2021/06/python-how-to-check-url-health-periodically-by-python-script #25

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

python-How to check website or url health periodically and automatically by using python script?

  1. Purpose

https://www.bswen.com/2021/06/python-how-to-check-url-health-periodically-by-python-script.html

matteolavaggi commented 2 years ago

Many bug found:

1) Using python3 you need to change this import urllib.request with urllib.request.urlopen(url) as response: html = response.read()

to this a = = response.read()

2) Status not "200" for example 404 result in trowing an exception that bypass the "else" statement, so script never execute.