mirror of
https://gitee.com/xmz7891/ykxmz.git
synced 2026-10-18 10:10:43 +00:00
加线上官网验证测试 + 新官网截图
_tests/test_landing_live.py 检查线上(本机 + 公网)官网确实是新版: * 有数据带 / 评价区 / 平台标签行 / 滚动淡入脚本 * HTML 里没有裸 reveal(没 JS 时内容可见) * **没有管理页字眼**(对外的清洁度规矩) 实测 14/14 通过。
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
r'''验证线上官网已经是新版。'''
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "_build"))
|
||||
from devssh import run as ssh_run # noqa: E402
|
||||
|
||||
BASE = "https://relay.xxmxxs.top"
|
||||
UA = {"User-Agent": "LanRemote/1.8.2"}
|
||||
|
||||
passed = 0
|
||||
failed = 0
|
||||
|
||||
|
||||
def check(name, ok, detail=""):
|
||||
global passed, failed
|
||||
if ok:
|
||||
passed += 1
|
||||
print(" [PASS] " + name)
|
||||
else:
|
||||
failed += 1
|
||||
print(" [FAIL] " + name + ((" —— " + str(detail)) if detail else ""))
|
||||
|
||||
|
||||
def main() -> int:
|
||||
print("=" * 56)
|
||||
print(" 线上官网验证")
|
||||
print("=" * 56)
|
||||
|
||||
# 先用设备上的本机地址绕开 Cloudflare 缓存看个准的
|
||||
_c, local, _e = ssh_run(
|
||||
"curl -s --max-time 15 -H 'User-Agent: LanRemote/1.8.2' "
|
||||
"http://127.0.0.1:8080/", timeout=60, quiet=True)
|
||||
|
||||
# 再看公网(可能有最多 60 秒缓存)
|
||||
req = urllib.request.Request(BASE + "/", headers=UA)
|
||||
try:
|
||||
with urllib.request.urlopen(req, timeout=25) as resp:
|
||||
pub = resp.read().decode("utf-8", "replace")
|
||||
cc = resp.headers.get("cf-cache-status", "")
|
||||
ok_pub = True
|
||||
except Exception as exc: # noqa: BLE001
|
||||
pub = ""
|
||||
cc = ""
|
||||
ok_pub = False
|
||||
print(" 公网拉取失败:%s" % exc)
|
||||
|
||||
for label, html in (("本机", local or ""), ("公网", pub)):
|
||||
if not html:
|
||||
continue
|
||||
print()
|
||||
print(" ---- %s 版本 ----" % label)
|
||||
check("%s:是新版" % label, "scroll-hint" in html,
|
||||
"没有 scroll-hint,还是旧版")
|
||||
check("%s:有数据带" % label, 'class="stats"' in html, "没有")
|
||||
check("%s:有评价区" % label, 'class="quotes"' in html, "没有")
|
||||
check("%s:有平台标签行" % label, 'class="plats"' in html, "没有")
|
||||
check("%s:有滚动淡入脚本" % label,
|
||||
"IntersectionObserver" in html, "没有")
|
||||
check("%s:HTML 里没有裸 reveal(没 JS 也可见)" % label,
|
||||
"reveal\"" not in html.split("<script>")[0],
|
||||
"HTML 里还有 reveal,没 JS 会空白")
|
||||
check("%s:没有管理页字眼" % label, "管理页" not in html,
|
||||
"对外页面提到了管理页")
|
||||
|
||||
if ok_pub:
|
||||
print()
|
||||
print(" 公网 cf-cache-status: %s" % (cc or "(无)"))
|
||||
if cc.upper() == "HIT":
|
||||
print(" (HIT 说明拿到了缓存,新版最多 60 秒后生效)")
|
||||
|
||||
print()
|
||||
print("=" * 56)
|
||||
print(" 通过 %d 项,失败 %d 项" % (passed, failed))
|
||||
return 0 if failed == 0 else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user