98 lines
3.5 KiB
Python
98 lines
3.5 KiB
Python
|
|
"""Diagnose exactly what's blocking gfil-lab.com"""
|
||
|
|
import urllib.request, sys, io
|
||
|
|
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
|
||
|
|
|
||
|
|
# Test gfil-lab.com with various approaches
|
||
|
|
print("=== gfil-lab.com 诊断 ===\n")
|
||
|
|
|
||
|
|
# 1. Plain request (no UA)
|
||
|
|
print("[1] 无 User-Agent:")
|
||
|
|
try:
|
||
|
|
r = urllib.request.urlopen("https://gfil-lab.com/", timeout=10)
|
||
|
|
print(f" Status: {r.status}, URL: {r.url}")
|
||
|
|
except urllib.error.HTTPError as e:
|
||
|
|
print(f" HTTP {e.code} {e.reason}")
|
||
|
|
print(f" Server: {e.headers.get('Server','?')}")
|
||
|
|
print(f" CF-Ray: {e.headers.get('CF-Ray','?')}")
|
||
|
|
body = e.read().decode()[:300]
|
||
|
|
print(f" Body: {body}")
|
||
|
|
|
||
|
|
# 2. With browser UA
|
||
|
|
print("\n[2] 浏览器 User-Agent:")
|
||
|
|
try:
|
||
|
|
req = urllib.request.Request("https://gfil-lab.com/", headers={
|
||
|
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
|
||
|
|
})
|
||
|
|
r = urllib.request.urlopen(req, timeout=10)
|
||
|
|
print(f" Status: {r.status}, URL: {r.url}")
|
||
|
|
print(f" Size: {len(r.read())} bytes")
|
||
|
|
except urllib.error.HTTPError as e:
|
||
|
|
print(f" HTTP {e.code} {e.reason}")
|
||
|
|
body = e.read().decode()[:300]
|
||
|
|
print(f" Body: {body}")
|
||
|
|
|
||
|
|
# 3. Googlebot UA
|
||
|
|
print("\n[3] Googlebot User-Agent:")
|
||
|
|
try:
|
||
|
|
req = urllib.request.Request("https://gfil-lab.com/", headers={
|
||
|
|
"User-Agent": "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
|
||
|
|
})
|
||
|
|
r = urllib.request.urlopen(req, timeout=10)
|
||
|
|
print(f" Status: {r.status}, URL: {r.url}")
|
||
|
|
except urllib.error.HTTPError as e:
|
||
|
|
print(f" HTTP {e.code} {e.reason}")
|
||
|
|
body = e.read().decode()[:300]
|
||
|
|
print(f" Body: {body}")
|
||
|
|
|
||
|
|
# 4. Bingbot UA
|
||
|
|
print("\n[4] Bingbot User-Agent:")
|
||
|
|
try:
|
||
|
|
req = urllib.request.Request("https://gfil-lab.com/", headers={
|
||
|
|
"User-Agent": "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)"
|
||
|
|
})
|
||
|
|
r = urllib.request.urlopen(req, timeout=10)
|
||
|
|
print(f" Status: {r.status}, URL: {r.url}")
|
||
|
|
except urllib.error.HTTPError as e:
|
||
|
|
print(f" HTTP {e.code} {e.reason}")
|
||
|
|
body = e.read().decode()[:300]
|
||
|
|
print(f" Body: {body}")
|
||
|
|
|
||
|
|
# 5. robots.txt
|
||
|
|
print("\n[5] robots.txt:")
|
||
|
|
try:
|
||
|
|
req = urllib.request.Request("https://gfil-lab.com/robots.txt", headers={
|
||
|
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
|
||
|
|
})
|
||
|
|
r = urllib.request.urlopen(req, timeout=10)
|
||
|
|
content = r.read().decode()
|
||
|
|
print(f" Status: {r.status}")
|
||
|
|
print(f" Content: {content[:500]}")
|
||
|
|
except urllib.error.HTTPError as e:
|
||
|
|
print(f" HTTP {e.code} {e.reason}")
|
||
|
|
body = e.read().decode()[:300]
|
||
|
|
print(f" Body: {body}")
|
||
|
|
|
||
|
|
# 6. Check CF headers for challenge type
|
||
|
|
print("\n[6] 检查响应头详情:")
|
||
|
|
try:
|
||
|
|
req = urllib.request.Request("https://gfil-lab.com/", headers={
|
||
|
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
|
||
|
|
})
|
||
|
|
r = urllib.request.urlopen(req, timeout=10)
|
||
|
|
for h in ['Server', 'CF-Ray', 'CF-Cache-Status', 'X-Content-Type-Options', 'Content-Type']:
|
||
|
|
print(f" {h}: {r.headers.get(h, 'N/A')}")
|
||
|
|
except urllib.error.HTTPError as e:
|
||
|
|
print(f" HTTP {e.code}")
|
||
|
|
for h in ['Server', 'CF-Ray', 'CF-Cache-Status', 'Content-Type']:
|
||
|
|
print(f" {h}: {e.headers.get(h, 'N/A')}")
|
||
|
|
|
||
|
|
# 7. HTTP (non-HTTPS) test
|
||
|
|
print("\n[7] HTTP (非HTTPS):")
|
||
|
|
try:
|
||
|
|
r = urllib.request.urlopen("http://gfil-lab.com/", timeout=10)
|
||
|
|
print(f" Status: {r.status}, URL: {r.url}")
|
||
|
|
except urllib.error.HTTPError as e:
|
||
|
|
print(f" HTTP {e.code} {e.reason}")
|
||
|
|
except Exception as e:
|
||
|
|
print(f" Error: {type(e).__name__}: {e}")
|