48 lines
1.6 KiB
Python
48 lines
1.6 KiB
Python
import base64
|
|
import json
|
|
import requests
|
|
from Crypto.Cipher import AES
|
|
from Crypto.Util.Padding import unpad
|
|
|
|
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": f"{BASE}/novel-2058540.html",
|
|
"Accept": "application/json, text/plain, */*",
|
|
}
|
|
nid = 2058540
|
|
|
|
def js_to_string(n, base):
|
|
digits = "0123456789abcdefghijklmnopqrstuvwxyz"
|
|
s = ""
|
|
while n:
|
|
s = digits[n % base] + s
|
|
n //= base
|
|
return s or "0"
|
|
|
|
def decrypt_content(content):
|
|
e = "iGzsYn" + js_to_string(int("165455", 14), 32)
|
|
iv_str = "$h$b3!" + e
|
|
t = base64.b64decode("dTBMUnJidSRFbg==").decode()
|
|
key_str = t + js_to_string(int("4d5a6c8", 14), 36) + "A"
|
|
key, iv = key_str.encode(), iv_str.encode()
|
|
raw = base64.b64decode(content)
|
|
cipher = AES.new(key, AES.MODE_CBC, iv)
|
|
return unpad(cipher.decrypt(raw), 16).decode("utf-8")
|
|
|
|
info = requests.get(WEBAPI + f"/novel/novelInfo?id={nid}", headers=headers, timeout=30).json()
|
|
print("novel", info["data"]["novel_name"], info["data"]["novel_wordnumber"])
|
|
|
|
clist = requests.get(WEBAPI + f"/novel/chapterGetList?nid={nid}", headers=headers, timeout=30).json()
|
|
chapters = clist["data"]["list"]
|
|
print("chapters", len(chapters))
|
|
for ch in chapters[:3]:
|
|
cid = ch["id"]
|
|
r = requests.get(WEBAPI + f"/novel/chapterGetInfo?nid={nid}&cid={cid}", headers=headers, timeout=30)
|
|
ci = r.json()["data"]["chapterInfo"]
|
|
enc = ci.get("content") or ""
|
|
text = decrypt_content(enc) if enc else ""
|
|
print(ch["name"][:40], "enc", len(enc), "text", len(text), text[:80].replace("\n", " "))
|