Files
SnarfCode/scripts/test_syno_asset_snarfnas.py

22 lines
753 B
Python

import urllib.request
import ssl
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
url = "https://snarfnas.snarfnet.net/webapi/entry.cgi?api=SYNO.Core.Desktop.UIString&version=1&method=getjs&lang=enu"
req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0"})
try:
with urllib.request.urlopen(req, context=ctx, timeout=10) as resp:
print("Status:", resp.status)
content = resp.read()
print("Length:", len(content))
print("Preview:", content[:200].decode('utf-8', errors='replace'))
except urllib.error.HTTPError as e:
print("HTTPError:", e.code, e.reason)
print("Location:", e.headers.get('Location'))
except Exception as e:
print("Error:", e)