probe_srvlist2.py 1.8 KB

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