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

**Job ID:** 94d230f73e7f
**Run Time:** 2026-06-23 18:30:02
**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

## 执行结果：项目文件不存在，无法完成

**任务失败。** 服务器上缺少该项目所需的所有文件和环境。

### 问题诊断

| 检查项 | 状态 |
|--------|------|
| `/home/agentuser/` 用户目录 | ❌ 不存在（无此用户） |
| `/home/agentuser/project/scripts/` | ❌ 不存在 |
| `fetch_articles.py` | ❌ 全系统找不到 |
| `.env` 含 `QW_WEBHOOK_URL` / `WE_MP_RSS_AK` / `WE_MP_RSS_SK` | ❌ 不存在 |
| `utils.py`（含 `send_qw_markdown`、`load_pending`、`save_pending`） | ❌ 不存在 |
| `DEEPSEEK_API_KEY` 仅存在于 `/home/ubuntu/.hermes/.env`（Hermes 自身配置） | ⚠️ 非项目 .env |

### 当前服务器环境

- 用户：`ubuntu`（无 `agentuser`）
- 可用目录：`/home/ubuntu/hermes-migration/scripts/`（仅含小红书写题脚本，非微信公众号抓取项目）

### 需要做的事

1. **创建 `agentuser` 用户**并部署项目文件到 `/home/agentuser/project/`
2. **准备以下文件：**
   - `scripts/fetch_articles.py` — 包含 `main()` 函数，抓取公众号文章并存入 pending
   - `scripts/utils.py` — 包含 `send_qw_markdown()`、`load_pending()`、`save_pending()` 
   - `../.env` — 包含 `DEEPSEEK_API_KEY`、`QW_WEBHOOK_URL`、`WE_MP_RSS_AK`、`WE_MP_RSS_SK`
3. 安装所需 Python 依赖

项目源码是否在另一台服务器上？需要从源服务器同步过来。
