Python Notes: http website tester
- The information presented here is intended for educational use.
- The information presented here is provided free of charge, as-is, with no warranty of any kind.
- Edit: 2023-09-24
http website tester
#!/bin/python3
'''
============================================================
title : http_website_tester_100.py
author : Neil Rieck
created: 2023-09-23
purpose: just want to view the http header:
1) "link" with rel="canonical" (required by Google)
2) cache settings
history:
ver who when what
100 NSR 230923 original effort
============================================================
'''
import requests
import sys
#
url_list = [
"https://neilrieck.net/links/openvms_resources.html",
"https://neilrieck.net/links/openvms_resources.html"
]
#
try:
print(f"-i-program: {sys.argv[0]}")
sess = requests.Session() # maintains cookies, etc.
test = 0
for url in url_list:
test += 1
print("*"*60, f" start-of-test: {test}")
print(f"url : {url}")
r = sess.get(url, timeout=5)
print(f"status : {r.status_code}")
print(f"headers : {r.headers}")
print("header-items:")
for x in r.headers:
print(f"{x: <24}", " ", r.headers[x])
if ( 1 == 0):
print("body:")
print(r.text)
print("*"*60, f" end-of-test: {test}\n")
print("-i-normal exit")
except Exception as e:
print(f"Error: {e}")
# this is the end
Links
Back to
Home
Neil Rieck
Waterloo, Ontario, Canada.