# -*- coding: utf-8 -*- r'''抓新版管理页到本地做截图(要带登录 cookie)。''' from __future__ import annotations import sys from pathlib import Path ROOT = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote") sys.path.insert(0, str(ROOT / "_build")) from devssh import run # noqa: E402 def main() -> int: # 在设备上登录拿 cookie,再抓页面,然后把 cookie 去掉后存本地 _c, out, _e = run( "PASS=$(cat /root/lanremote-relay/data/admin_password.txt); " "curl -s -c /tmp/ck.txt -o /dev/null " "-d \"username=xmz7891&password=$PASS\" " "http://127.0.0.1:8080/admin/login; " "curl -s -b /tmp/ck.txt --max-time 20 " "http://127.0.0.1:8080/zhongzhuanzhan", timeout=120) if not out or "ykxmz 中转站" not in out: print(" 抓不到管理页") print(out[:300]) return 1 # 本地 file:// 打开时相对路径全失效,改绝对 out = out.replace('href="/favicon.ico"', 'href="https://relay.xxmxxs.top/favicon.ico"') target = ROOT / "_build" / "admin_new.html" target.write_text(out, encoding="utf-8") print(" 抓到 %d 字符 -> %s" % (len(out), target.name)) return 0 if __name__ == "__main__": sys.exit(main())