|
|
|
@ -3,10 +3,30 @@ import re
|
|
|
|
import demjson3 as demjson
|
|
|
|
import demjson3 as demjson
|
|
|
|
import json
|
|
|
|
import json
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 创建全局 session 并设置浏览器 UA
|
|
|
|
|
|
|
|
session = requests.Session()
|
|
|
|
|
|
|
|
COMMON_HEADERS = {
|
|
|
|
|
|
|
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
|
|
|
|
|
|
|
|
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8",
|
|
|
|
|
|
|
|
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
|
|
|
|
|
|
|
|
"Accept-Encoding": "gzip, deflate, br",
|
|
|
|
|
|
|
|
"Connection": "keep-alive",
|
|
|
|
|
|
|
|
"Upgrade-Insecure-Requests": "1",
|
|
|
|
|
|
|
|
"sec-ch-ua": '"Google Chrome";v="120", "Chromium";v="120", "Not:A-Brand";v="99"',
|
|
|
|
|
|
|
|
"sec-ch-ua-mobile": "?0",
|
|
|
|
|
|
|
|
"sec-ch-ua-platform": '"Windows"',
|
|
|
|
|
|
|
|
"Sec-Fetch-Site": "same-origin",
|
|
|
|
|
|
|
|
"Sec-Fetch-Mode": "navigate",
|
|
|
|
|
|
|
|
"Sec-Fetch-User": "?1",
|
|
|
|
|
|
|
|
"Sec-Fetch-Dest": "document",
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
session.headers.update(COMMON_HEADERS)
|
|
|
|
|
|
|
|
session.cookies.set("visited", "1") # 提高拟真度
|
|
|
|
|
|
|
|
|
|
|
|
# 下载伪 JSON 文本
|
|
|
|
# 下载伪 JSON 文本
|
|
|
|
def fetch_raw_json():
|
|
|
|
def fetch_raw_json():
|
|
|
|
url = "https://www.xn--sss604efuw.com/jm/jiemi.php?url=http%3A%2F%2Fwww.%E9%A5%AD%E5%A4%AA%E7%A1%AC.com%2Ftv"
|
|
|
|
url = "https://www.xn--sss604efuw.com/jm/jiemi.php?url=http%3A%2F%2Fwww.%E9%A5%AD%E5%A4%AA%E7%A1%AC.com%2Ftv"
|
|
|
|
resp = requests.get(url, timeout=30)
|
|
|
|
resp = session.get(url, timeout=30, allow_redirects=True)
|
|
|
|
resp.encoding = 'utf-8'
|
|
|
|
resp.encoding = 'utf-8'
|
|
|
|
return resp.text
|
|
|
|
return resp.text
|
|
|
|
|
|
|
|
|
|
|
|
@ -18,7 +38,7 @@ def extract_and_save_spider(json_text):
|
|
|
|
full_spider = match.group(1)
|
|
|
|
full_spider = match.group(1)
|
|
|
|
spider_url = full_spider.split(";")[0]
|
|
|
|
spider_url = full_spider.split(";")[0]
|
|
|
|
print(f"📥 下载 spider 文件: {spider_url}")
|
|
|
|
print(f"📥 下载 spider 文件: {spider_url}")
|
|
|
|
resp = requests.get(spider_url, timeout=30)
|
|
|
|
resp = session.get(spider_url, timeout=30, allow_redirects=True)
|
|
|
|
with open("fan.txt", "wb") as f:
|
|
|
|
with open("fan.txt", "wb") as f:
|
|
|
|
f.write(resp.content)
|
|
|
|
f.write(resp.content)
|
|
|
|
print("✅ 已保存为 fan.txt")
|
|
|
|
print("✅ 已保存为 fan.txt")
|
|
|
|
@ -71,4 +91,3 @@ if __name__ == "__main__":
|
|
|
|
save_json(data)
|
|
|
|
save_json(data)
|
|
|
|
except Exception as e:
|
|
|
|
except Exception as e:
|
|
|
|
print(f"❌ 错误: {e}")
|
|
|
|
print(f"❌ 错误: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|