> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.beatapi.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.beatapi.io/_mcp/server.

# 用Python复盘公众号内容，怎样把文章目录和互动统计接到同一轮研究？

> 确认公众号，保存文章目录并选择研究样本，再取统计并复用指标导出器，交付可核对的阅读清单与内容复盘。

用 Python 复盘公众号内容时，先用 `wechat_mp.v2.fetch_account_articles` 保存一页文章目录并选出相关文章，再用 `wechat_mp.v2.fetch_article_stats` 保存每篇入选文章的统计，最后用现有的 `wechat_metrics.py` 导出器把统计转成 CSV。例如要研究一个行业公众号最近怎样讲产品教程：先列出账号发了什么，再选出教程类文章，查看这些文章在当前观察时点的阅读与互动。最终交付文章名单、指标、原文依据和下一步值得研究的问题。

已经知道文章链接时，直接从第 4 步读统计；要了解账号近期写了哪些主题时，从第 2 步的文章目录开始。

## 1. 确认账号和本轮问题

先固定目标账号和研究问题，例如“近期教程都解释了哪些使用步骤”。已有核实的 `username` 就复用；只有这个账号的一篇文章时，按[账号标识交接](/zh/faq/wechat-account-identifier)取得 `data.content.user_name`。展示昵称只用来确认来源，不直接填成账号标识。

`wechat_mp.v2.fetch_account_articles` 的 `username` 接受 `gh_…`、`gh_…@app` 和自定义微信号。文章目录流程（见第 3 步）里现有的历史处理器只接受规范的 `gh_` 标识，准备接着用历史处理器时就使用 `gh_` 标识。其他有效写法仍可保存目录原件；把这项兼容差异和保存的文件一起记下。

一页目录加上三篇教程各一次统计，最多四次请求。需要从文章定位账号、回溯更多目录页或读取正文时，再加相应步骤。现价见[价格页](https://beatapi.io/zh/pricing)。

## 2. 用Python保存一批材料

使用 Python 3 标准库，在本地环境配置 `BEATAPI_API_KEY`。把下面的代码保存为 `mp_read.py`；`mp_read.py` 每次运行把一页文章目录（`list`）或一篇文章的标准统计（`stats`）保存到一个新目录。

```python
import json
import os
import sys
from datetime import datetime, timezone
from pathlib import Path
from urllib.error import HTTPError, URLError
from urllib.request import Request, urlopen

if len(sys.argv) != 4 or sys.argv[1] not in {"list", "stats"}:
    raise SystemExit("Usage: python3 mp_read.py list|stats VALUE NEW_DIRECTORY")
mode, value, directory = sys.argv[1:]
if not value.strip():
    raise SystemExit("Supply a verified account username or article URL")
key = os.environ.get("BEATAPI_API_KEY")
if not key:
    raise SystemExit("Set BEATAPI_API_KEY in your local environment")
if mode == "list":
    action = "wechat_mp.v2.fetch_account_articles"
    params = {"username": value, "offset": "", "item_show_type": 0, "raw": False}
else:
    action = "wechat_mp.v2.fetch_article_stats"
    params = {"url": value, "raw": True}
body = {"action": action, "params": params}
out = Path(directory)
out.mkdir(parents=True, exist_ok=False)
(out / "request.json").write_text(json.dumps(body, ensure_ascii=False, indent=2), encoding="utf-8")
started = datetime.now(timezone.utc).isoformat()
(out / "attempt.json").write_text(json.dumps({"started_at": started, "action": action}), encoding="utf-8")
request = Request("https://api.beatapi.io/v1/social-data/call",
                  data=json.dumps(body).encode("utf-8"), method="POST",
                  headers={"Authorization": "Bearer " + key, "Content-Type": "application/json"})
try:
    with urlopen(request, timeout=60) as response:
        status, raw = response.status, response.read()
except HTTPError as error:
    status, raw = error.code, error.read()
except URLError:
    (out / "transport-error.json").write_text(json.dumps({"outcome": "unknown", "action": action}), encoding="utf-8")
    raise SystemExit("No final response saved; review the attempted request before repeating")
(out / "response.json").write_bytes(raw)
(out / "call.json").write_text(json.dumps({"action": action, "params": params,
    "http_status": status, "started_at": started,
    "finished_at": datetime.now(timezone.utc).isoformat(),
    "response_file": "response.json", "platform_review": "required"},
    ensure_ascii=False, indent=2), encoding="utf-8")
try:
    payload = json.loads(raw)
except (ValueError, UnicodeError):
    raise SystemExit("Saved a non-JSON response; inspect response.json")
if status != 200 or not isinstance(payload, dict) or payload.get("status") != "succeeded" or payload.get("error") is not None or payload.get("action") != action:
    raise SystemExit("Saved a failed or unexpected response; inspect response.json")
print("Saved response for platform-content review: " + str(out / "response.json"))
```

取得目标账号的文章目录：

```bash
python3 mp_read.py list '<confirmed_username>' mp-list-01
```

`list` 模式显式使用 `raw:false`、文章栏目 `0` 和空 `offset`，与已有目录流程一致。`page_size` 可能被忽略，不要按一页固定 20 篇安排统计。原始响应保存在 `response.json`，请求条件和时间保存在 `call.json`，后续读取可以复用这两个文件。

## 3. 从目录选要研究的文章

1. 确认 `response.json` 里是目标账号和目标栏目。
2. 查看实际标题、摘要、链接和发布时间。
3. 把教程、活动宣传和新闻转载分开。
4. 为每篇文章写入选或排除理由，形成固定的研究名单。

例如一篇讲首次安装、一篇讲日常操作、一篇讲故障排查，三篇都属于教程，但目的和读者处境不同。目录只给线索；讨论具体写法时，再补读相应正文。

要继续读历史目录时，按[文章目录流程](/zh/guides/wechat-account-articles)传回真实的 `next_offset`，不要把文章数量填进 `offset`。文章目录流程提供目录 CSV 和历史状态处理器；`mp_read.py` 只保存首批原件，续页交给文章目录流程。

## 4. 为选定文章读取统计

确认文章 URL 后运行：

```bash
python3 mp_read.py stats '<confirmed_article_url>' mp-stats-01
```

每篇文章使用一个新的输出目录。`wechat_mp.v2.fetch_article_stats` 接受公开短链和 `__biz` 长链；保留 `raw:true`，把数字和显示/取数状态一起保存。指标含义和当前快照的读法见[活动文章复盘](/zh/guides/wechat-article-performance-review)。

目录条目和统计通过实际请求的 URL 关联。两篇文章标题相同时，也分别保留文章身份；重新取得同一篇文章的统计是一次新的观察，不覆盖上一时点的快照。

## 5. 接已有CSV导出，而不是重新取数

从[阅读与互动问答](/zh/faq/wechat-article-metrics)保存 `wechat_metrics.py`。在 `stats-pages.json` 里为每份实际统计原件建一条记录：

1. `http_status` 从这份原件的 `call.json` 原样复制。
2. `collected_at` 填 `call.json` 里的 `finished_at`。
3. `response_file` 写成相对 `stats-pages.json` 所在目录的原件路径。

把下面示例里的值换成实际值：

```json
[
  {
    "action": "wechat_mp.v2.fetch_article_stats",
    "params": {"url": "https://mp.weixin.qq.com/s/example", "raw": true},
    "http_status": 200,
    "collected_at": "2026-11-17T08:00:00+08:00",
    "response_file": "mp-stats-01/response.json"
  }
]
```

在本地转换已保存的响应：

```bash
python3 wechat_metrics.py stats-pages.json mp-review-01
```

`metrics.csv` 是每篇文章每个指标一行的长表，文章数量要另算。用 URL 和原件来源找回对应文章；标题、内容目的和入选理由来自目录和你的选文表。需要把正文与统计联表时，用[来源与统计联表](/zh/faq/wechat-page-fields)，每批最多五对文章。

## 6. 怎样把指标表变成复盘？

先分清每篇文章的目的、积累时间和数据状态，再看值得补读的差异。整数、显示阈值、缺失和失败分别保留。今天的统计只说明当前观察；发布后第七天的比较需要第七天当时保存的统计。

交付目录、选文理由、统计长表、原件和三到五个具体复盘问题，例如“安装教程是否把准备步骤交代清楚”“高收藏的操作文章哪些结构值得借鉴”，每个问题附证据和下一步。阅读和点赞数提示该看哪些文章，具体解释还要回到原文。

例如同一批里一篇是快速上手、一篇是旧版迁移。先按每篇文章的目的读指标，再把「核对哪篇的开头说清了适用版本」列成复盘项，附上保存的统计文件和原文链接，团队下次可以直接接着这个问题读。

把复盘交给已接入 BeatAPI 的助手时，可以这样布置：

> 研究目标公众号近期的教程，复用已核实的账号标识，取一页目录挑出相关文章。为选定的三篇文章保存标准统计，复用已有导出器；按文章目的、发布时长和状态解释差异，再列出值得读原文的问题。交付文章名单、入选理由、指标和来源，说明实际覆盖范围。