18 lines
541 B
Python
18 lines
541 B
Python
import urllib.request
|
|
import ssl
|
|
|
|
ctx = ssl.create_default_context()
|
|
ctx.check_hostname = False
|
|
ctx.verify_mode = ssl.CERT_NONE
|
|
|
|
url = "https://sn-nas.snarfnet.net/"
|
|
req = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)'})
|
|
try:
|
|
with urllib.request.urlopen(req, context=ctx, timeout=8) as resp:
|
|
content = resp.read().decode('utf-8', errors='ignore')
|
|
print("HTML length:", len(content))
|
|
print("HTML contents:\n", content)
|
|
except Exception as e:
|
|
print("Error:", e)
|
|
|