Files
SnarfCode/scripts/test_homepage_static.py

14 lines
542 B
Python

import urllib.request, ssl
ctx = ssl._create_unverified_context()
for path in ['/topology.png', '/topology.html']:
url = 'https://homepage.snarfnet.net' + path
try:
req = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0'})
with urllib.request.urlopen(req, context=ctx, timeout=10) as r:
data = r.read()
print(f'{url} -> HTTP {r.status}, length: {len(data)} bytes, Content-Type: {r.headers.get("Content-Type")}')
except Exception as e:
print(f'{url} -> Error: {e}')