Files
SnarfCode/scripts/check_snarfhome_response.py

25 lines
738 B
Python

import urllib.request
import ssl
import sys
sys.stdout.reconfigure(encoding='utf-8')
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
req = urllib.request.Request("https://snarfhome.snarfnet.net/")
try:
with urllib.request.urlopen(req, timeout=5, context=ctx) as r:
print("Status:", r.getcode())
print("Headers:", dict(r.headers))
content = r.read().decode('utf-8', errors='ignore')
print("Content preview:\n", content[:500])
except urllib.error.HTTPError as e:
print("HTTPError:", e.code)
print("Headers:", dict(e.headers))
print("Body:\n", e.read().decode('utf-8', errors='ignore')[:500])
except Exception as e:
print("Exception:", e)