#!/bin/bash # 用无头 Chrome 真实加载页面,抓 DOM 与控制台错误 CHROME="${CHROME_BIN:-/tmp/pwbrowsers/chromium_headless_shell-1255/chrome-headless-shell-linux64/chrome-headless-shell}" URL="${1:-http://127.0.0.1:8588/index.html}" OUT="${2:-/tmp/dom.html}" ERR="/tmp/chrome-console.log" : > "$ERR" timeout 60 "$CHROME" \ --no-sandbox --disable-gpu --disable-dev-shm-usage \ --headless --virtual-time-budget=8000 \ --enable-logging=stderr --v=0 \ --dump-dom "$URL" > "$OUT" 2>"$ERR" echo "DOM bytes: $(stat -c%s "$OUT" 2>/dev/null || echo 0)" echo "=== 关键错误 ===" grep -i -E "error|failed|refused|not found|404|Uncaught|SyntaxError|TypeError" "$ERR" | grep -v -i -E "GCM|Registration|gpu|Vulkan|dbus|fonts|Fontconfig|sandbox|DevTools" | head -15 echo "=== 页面正文长度 ===" python3 -c " import re,sys h=open('$OUT',encoding='utf-8',errors='replace').read() t=re.sub(r'','',h,flags=re.S) t=re.sub(r'','',t,flags=re.S) t=re.sub(r'<[^>]+>',' ',t) t=re.sub(r'\s+',' ',t).strip() print('text len:',len(t)) print('text:',t[:400]) "