"""Probe gongzicp.com HTML/API structure.""" from __future__ import annotations import json import re import requests UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/124.0.0.0" BASE = "https://www.gongzicp.com" def fetch(path: str) -> str: url = path if path.startswith("http") else f"{BASE}{path}" r = requests.get(url, headers={"User-Agent": UA, "Referer": BASE + "/"}, timeout=45) print(f"GET {url} -> {r.status_code} len={len(r.text)}") return r.text def main() -> None: html = fetch("/novel-429598.html") # API hints for line in html.splitlines(): lower = line.lower() if any(k in lower for k in ("api", "chapter", "catalog", "novelid", "read")): if len(line.strip()) < 300: print(line.strip()[:200]) # chapter links chapters = re.findall(r'href="([^"]*chapter[^"]*)"', html, re.I) print("chapter hrefs sample:", chapters[:10]) chapters2 = re.findall(r'href="(/read/\d+[^"]*)"', html) print("read hrefs:", chapters2[:10]) chapters3 = re.findall(r'novel-\d+', html) print("novel ids in page:", list(set(chapters3))[:5]) print("html preview:", html[:2000]) # try search API guesses for api in [ "/webapi/search/novel?keyword=测试", "/api/search?keyword=测试", "/search?keyword=测试", ]: try: t = fetch(api) print(t[:500]) except Exception as exc: print(api, exc) if __name__ == "__main__": main()