"""Fetch the game serverlist for 玖扬复古176 (channel 110585) and find the TCP gateway.""" import asyncio import json import re import sys import httpx if hasattr(sys.stdout, "reconfigure"): sys.stdout.reconfigure(encoding="utf-8", errors="replace") async def main() -> None: url = "https://list-box.dhsf.xqhuyu.com/serverlist/110585/serverlist.txt" async with httpx.AsyncClient(timeout=15, follow_redirects=True) as c: r = await c.get(url) print(f"status: {r.status_code} len: {len(r.text)}") text = r.text # Find all dhsf hosts hosts = sorted(set(re.findall(r"[a-z0-9.-]+\.dhsf\.[a-z.]+", text))) print(f"dhsf hosts ({len(hosts)}):") for h in hosts[:15]: print(f" {h}") # Find port values ports = sorted(set(re.findall(r'"port"\s*:\s*(\d{3,5})', text))) print(f"port values: {ports}") # Find ip:port patterns ipp = sorted(set(re.findall(r'"(\d{1,3}(?:\.\d{1,3}){3})"\s*,\s*"port"', text))) print(f"ip fields: {ipp[:10]}") # Try parse as JSON and show structure of first entries try: data = r.json() if isinstance(data, list) and data: print(f"\nlist of {len(data)} servers; first server full record:") print(json.dumps(data[0], ensure_ascii=False, indent=2)[:900]) elif isinstance(data, dict): keys = list(data.keys()) print(f"\ndict with {len(keys)} keys: {keys[:8]}") first_key = keys[0] val = data[first_key] print(f"first value ({first_key}):") print(json.dumps(val, ensure_ascii=False, indent=2)[:900]) except Exception as e: print(f"JSON parse failed: {e}; raw[:400]: {text[:400]}") asyncio.run(main())