21 lines
737 B
Python
21 lines
737 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
|
|
|
|
for host in ["https://sn-nas.snarfnet.net", "https://snarfnas.snarfnet.net"]:
|
|
try:
|
|
req = urllib.request.Request(host, headers={"User-Agent": "Mozilla/5.0"})
|
|
with urllib.request.urlopen(req, context=ctx, timeout=8) as resp:
|
|
print(f"{host} -> Status: {resp.status}, Content-Length: {resp.headers.get('Content-Length')}")
|
|
body = resp.read().decode('utf-8', errors='replace')
|
|
print("Title/Body preview:", body[:300].replace('\n', ' '))
|
|
except Exception as e:
|
|
print(f"{host} -> Error: {e}")
|
|
|