31 lines
1013 B
Python
31 lines
1013 B
Python
import urllib.request
|
|
import ssl
|
|
import re
|
|
|
|
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) AppleWebKit/537.36"})
|
|
resp = urllib.request.urlopen(req, context=ctx)
|
|
html = resp.read().decode('utf-8', errors='replace')
|
|
tags = re.findall(r'<(?:script|link)[^>]+(?:src|href)="([^"]+)"', html)
|
|
|
|
failed = []
|
|
print(f"Testing {len(tags)} resources on sn-nas.snarfnet.net...")
|
|
for t in tags:
|
|
res_url = f"https://sn-nas.snarfnet.net/{t}"
|
|
try:
|
|
r = urllib.request.Request(res_url, headers={"User-Agent": "Mozilla/5.0"})
|
|
with urllib.request.urlopen(r, context=ctx, timeout=5) as res:
|
|
if res.status != 200:
|
|
failed.append((res_url, res.status))
|
|
except Exception as e:
|
|
failed.append((res_url, str(e)))
|
|
|
|
print(f"Finished. Failures: {len(failed)}")
|
|
for f in failed:
|
|
print(" ", f)
|
|
|