# Cron Job: 春考选题-文章抓取

**Job ID:** 94d230f73e7f
**Run Time:** 2026-06-24 10:43:33
**Schedule:** every 120m

## Prompt

[IMPORTANT: You are running as a scheduled cron job. DELIVERY: Your final response will be automatically delivered to the user — do NOT use send_message or try to deliver the output yourself. Just produce your report/output as your final response and the system handles the rest. SILENT: If there is genuinely nothing new to report, respond with exactly "[SILENT]" (nothing else) to suppress delivery. Never combine [SILENT] with content — either report your findings normally, or say [SILENT] and nothing more.]

在服务器上抓取微信公众号最新文章，然后推送到企微群。

步骤：
1. cd /home/agentuser/project/scripts
2. 设置环境变量：export DEEPSEEK_API_KEY=$(grep DEEPSEEK_API_KEY ../.env | cut -d= -f2) && export QW_WEBHOOK_URL=$(grep QW_WEBHOOK_URL ../.env | cut -d= -f2-) && export WE_MP_RSS_AK=$(grep WE_MP_RSS_AK ../.env | cut -d= -f2) && export WE_MP_RSS_SK=$(grep WE_MP_RSS_SK ../.env | cut -d= -f2)
3. 运行 python3 -c "
import os, sys
sys.path.insert(0, '.')
from utils import send_qw_markdown
from fetch_articles import main as fetch_main

# Step 1: Fetch
fetch_main()

# Step 2: Check pending articles
from utils import load_pending
pending = load_pending()
articles = pending.get('articles', [])
new_articles = [a for a in articles if not a.get('processed')]

if not new_articles:
    print('No new articles to push')
else:
    # Push each new article
    count = 0
    for art in new_articles[:5]:  # max 5 per run
        title = art.get('title', '无标题')
        url = art.get('url', '')
        source = art.get('source', '未知来源')
        summary = art.get('summary', '')[:200]
        content = f'## 📰 {title}\n> 来源：{source}\n\n{summary}\n\n[阅读原文]({url})'
        if send_qw_markdown(content):
            art['processed'] = True
            count += 1
            print(f'Pushed: {title[:40]}')
    
    from utils import save_pending
    save_pending(pending)
    print(f'Total pushed: {count}/{len(new_articles)}')
" 2>&1

不用问我任何问题，直接执行。

## Response

## 执行结果：失败

脚本已按步骤执行，但微信公众号文章抓取环节失败。详细诊断如下：

---

### 失败原因

**1. API 密钥为占位符（主要原因）**

```
WE_MP_RSS_AK = "PLACEHOLDER_AK" (14字符)
```

`.env` 文件中 `WE_MP_RSS_AK` 的值是占位符，不是真实有效的 WeMP API 密钥。即使网络连通，API 也会返回鉴权错误。

**2. WeMP API 端点 SSL 握手失败（网络层阻断）**

```
Host: api.wemp.com → 64.190.63.222
TCP 443: ✅ 可达
TLS Client Hello: 已发送
服务器响应: ❌ 直接关闭连接（read 0 bytes）
OpenSSL 诊断: ssl3_read_n: unexpected eof while reading
```

| 测试方式 | 结果 |
|---------|------|
| Python requests (默认) | `SSLEOFError` |
| curl (TLS 1.3) | `SSL_ERROR_SYSCALL` |
| curl --insecure | 同上 |
| curl --tlsv1.2 | 同上 |
| openssl s_client | `unexpected eof while reading` |

无论使用何种 TLS 版本或是否验证证书，服务器均在收到 Client Hello 后直接关闭 TCP 连接，不返回任何 TLS 握手数据。该行为特征更像是**网络中间设备（防火墙/GFW/DPI）阻断了到该 IP 的 HTTPS 流量**，而非服务端配置问题。

---

### 需要修复

1. **更新 `.env` 中的真实 API 凭证**：将 `WE_MP_RSS_AK` 和 `WE_MP_RSS_SK` 替换为 WeMP 官方颁发的有效密钥
2. **网络连通性**：`api.wemp.com` (64.190.63.222) 的 443 端口在当前服务器网络环境中被阻断，可能需要：
   - 配置代理出口
   - 更换到国内服务器执行
   - 或者确认该 API 是否有其他可访问的域名/IP

修复上述两项后，重新运行该 cron 任务即可正常抓取和推送。
