Files

37 lines
1.1 KiB
Python
Raw Permalink Normal View History

2026-11-16 20:45:22 +08:00
import json
import requests
UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/124.0.0.0"
BASE = "https://www.gongzicp.com"
WEBAPI = BASE + "/webapi"
headers = {
"User-Agent": UA,
"Referer": BASE + "/",
"Accept": "application/json, text/plain, */*",
}
s = requests.Session()
s.headers.update(headers)
init = s.get(WEBAPI + "/system/init", timeout=30).json()
print("init", init)
# chapter with nid param
for nid, cid in [(429598, 2377724), (100000, 1)]:
r = s.get(
WEBAPI + f"/novel/chapterGetInfo?nid={nid}&cid={cid}",
headers={"Referer": f"{BASE}/read-{nid}-{cid}.html"},
timeout=30,
)
data = r.json()
if data.get("code") == 200:
ci = data.get("data", {}).get("chapterInfo", {})
print(nid, cid, "content len", len(ci.get("content") or ""), "number", ci.get("number"))
# try search with session cookies
r = s.get(
WEBAPI + "/novel/searchNovel",
params={"keyword": "天官", "page": 1, "num": 10},
headers={"Referer": f"{BASE}/search.html"},
timeout=30,
)
print("search", r.status_code, r.text[:500])