#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""qc_listfix_probe.py —— 2 个「列表抓空」脚本：完整输出 + 列表解析方式"""
import re, subprocess
D = "/root/gov_crawler/"
for f in ("crawl_jxth.py", "crawl_dawu.py"):
    src = open(D + f, encoding="utf-8", errors="ignore").read()
    print("═" * 78)
    print("【%s】%d 字节" % (f, len(src)))
    m = re.findall(r'(?:LIST_URL|list_url|BASE_URL|URL)\s*=\s*["\']([^"\']+)["\']', src)
    print("  列表URL常量:", m[:3])
    # 列表解析：findall/select/re.compile
    for pat in (r'(re\.compile\(\s*["\'][^"\']{0,120})', r'(soup\.select\(\s*["\'][^"\']{0,80})',
                r'(find_all\(\s*["\'][^"\']{0,60})', r'(xpath\([^)]{0,80})'):
        g = re.findall(pat, src)
        if g: print("  解析:", g[:2])
    r = subprocess.run(["python3", D + f], capture_output=True, text=True, timeout=90, cwd=D)
    print("  EXIT=%d" % r.returncode)
    outs = [x for x in (r.stdout or "").split("\n") if x.strip()]
    print("  ── stdout (%d 行) ──" % len(outs))
    for x in outs[:12]: print("    ", x[:118])
    errs = [x for x in (r.stderr or "").split("\n") if x.strip()]
    if errs:
        print("  ── stderr (末 6 行) ──")
        for x in errs[-6:]: print("    ", x[:118])
