> 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.

# 同行 X 账号这次有什么值得跟进？怎么只整理新看到的动态？

> 通过 twitter.web.fetch_user_post_tweet 首页响应建立公开 X 账号基线，用 watch_account.py 逐轮比对新观察到的帖子 ID，并附首页覆盖边界输出变化摘要。

要跟进一个公开 X 账号，先用 `twitter.web.fetch_user_post_tweet` 取账号时间线的第一页，保存为基线。之后每轮重新取第一页，运行 `watch_account.py` 按帖子 ID 和已保存的状态比对，找出本地没见过的帖子。发布时间和发现时间分开记录，再挑出产品更新、活动或值得跟进的讨论。

例如这轮第一次看到一条上周发布的置顶帖，就把这条帖子列为「本轮发现的旧帖」。真正在这次新发布的版本通知，保留原帖和生效日期，交给同事跟进。

## 第一次先建基线，别把整页当新消息

确认 handle 对应的是你要研究的公开账号，保存这次的首页响应和实际观察时间。首次导出的 `new-posts.csv` 只有表头，因为第一轮是在建立起点，不代表账号没有内容。之后每轮都从上次已验收的状态继续比较，历次输出全部保留，不覆盖证据。

账号改名、同名被重用或身份无法确认时，先重新核对账号身份并重建基线；`watch_account.py` 不会自行验证账号所有权的连续性。只是重新整理数据时，直接在本地比较已保存的响应，不要再买一次首页查询。

## 新出现的条目，哪些值得团队看？

下表是常见变化的审核方法：

| 看到的变化           | 先核对什么             | 摘要里怎么写                     |
| --------------- | ----------------- | -------------------------- |
| 产品功能或活动公告       | 原文、日期、具体开放条件      | 记录公开宣布了什么、为何与我们有关、下一步要查什么。 |
| 首次看到但发布时间较早     | 是否只是本轮才进入可见首页     | 写“本轮首次观察到旧帖”，不写“今日新发”。     |
| 转推他人内容          | 目标账号的动作与原作者内容分别看  | 不把他人的发布或立场全部归给目标账号。        |
| 置顶内容变化或旧编号不再在首页 | 查独立置顶记录、可见范围和原始文件 | 不把首页缺席推成删除，也不把置顶自动算新发布。    |
| 本轮没有新增条目        | 看采集是否成功、首页覆盖多少    | 只说明这轮没有新观察到的ID，不证明期间完全没发帖。 |

是否值得关注由人判断。互动更高不等于商业机会，单个公开账号的活动也不能代表整个行业在增长。

## 交一份能接着研究的变化摘要

保留账号、前后两次观察时间、本轮新观察到的 ID、原帖来源、具体变化、与业务的关系和下一步核查。`new-posts.csv` 是候选清单；编辑理由、负责人和完成状态写在另存的工作表里，`watch_account.py` 不会填写这些列，也不分派任务。

先看本轮 `coverage.json` 里的条数和遗漏边界，抽查原始证据后，再接受本轮新的 `state.json`。每天只看首页，可能漏掉两次观察之间发布的帖子；补历史需要另外批准范围，不能把历史页当成下一次日常检查点。把“只看首页”这个限制写进摘要，避免“没看到”被理解成“没发生”。

例如观察 20 个账号时，每个账号的基线和最后成功时间分开保存。某个账号当天读取失败时，摘要照常交付其他账号的变化，把失败的账号单独标记待补。这个账号恢复读取后，用该账号最后一份有效状态比较。

## 按需要安排观察，先算账号数和轮次

需要新的观察时才发起账号请求，费用按“账号数 × 轮次 × 动作当前价格”估算；翻页、重试、模型分析和通知另算。不要因为某一页条数少就自动提高频率。先确认要解决的研究问题和可以接受的遗漏，再选定批准的观察节奏。

下面第 1–6 步是完整的取数和本地比较代码。`watch_account.py` 不会自行购买查询；是否采集新页、是否对外发送摘要，都由你单独决定。

## 1. 明确账号与费用上限

20 个账号每天各查一页，连续 30 天是 600 次列表请求。加页和模型分析另外计算。见 [BeatAPI 价格页](https://beatapi.io/zh/pricing)。

`screen_name` 填账号名，不带 @，也不填完整主页链接。`twitter.web.fetch_user_post_tweet` 另外支持整数 `rest_id`，两者同时填写时优先使用 `rest_id`，所以本流程只发送 `screen_name`。`twitter.web.fetch_user_post_tweet` 没有 tab 参数，帖子、回复、仅媒体和关键词提及不是同一个列表。

## 2. 保存一次首页观察

把实际目标账号填入 `request.json`：

```json
{"action":"twitter.web.fetch_user_post_tweet","params":{"screen_name":"<account_handle>"}}
```

批准这次查询后，把原始响应和响应头保存到新目录：

```bash
mkdir x-observation-1 && \
curl --fail-with-body -sS https://api.beatapi.io/v1/social-data/call \
  -H "Authorization: Bearer $BEATAPI_API_KEY" \
  -H 'Content-Type: application/json' \
  --data-binary @request.json \
  -D x-observation-1/response.headers \
  -o x-observation-1/response.json
```

记录真实的 HTTP 状态和带时区的采集时间。请求出错时，上一轮的监测状态保持不变；保留失败的原文件，不自动重试。要用完整的直接响应，不能把 AI 预览的前几项当成整页。

在响应目录旁保存 `observation.json`。下面只演示格式，所有值都替换成实际请求和观察：

```json
{"action":"twitter.web.fetch_user_post_tweet","params":{"screen_name":"<account_handle>"},"http_status":200,"collected_at":"2026-11-17T09:00:00+08:00","response_file":"x-observation-1/response.json"}
```

## 3. 先建基线，再比较下一次已存首页

把下面的代码保存为 `watch_account.py`，分两步运行：

1. 第一轮运行 `python3 watch_account.py observation.json - x-baseline`。横杠表示没有历史状态：本页返回的所有帖子都记作基线，`new-posts.csv` 只有表头。
2. 之后每轮运行 `python3 watch_account.py observation-next.json x-baseline/state.json x-next`。下一轮传入最新一份已验收的 `state.json` 路径，不要覆盖旧的输出目录。

```python
import csv
import hashlib
import json
import re
import sys
from datetime import datetime
from pathlib import Path

manifest, previous, output = sys.argv[1:]
manifest = Path(manifest)
entry = json.loads(manifest.read_text(encoding='utf-8'))
params = entry.get('params')
action = 'twitter.web.fetch_user_post_tweet'
if entry.get('action') != action or not isinstance(params, dict) or set(params) != {'screen_name'}:
    raise ValueError('Use one account homepage request: screen_name only, no cursor/rest_id')
handle = params['screen_name']
if not isinstance(handle, str) or not re.fullmatch(r'[A-Za-z0-9_]{1,15}', handle):
    raise ValueError('Use the handle without @ or a URL')
scope = handle.lower()
stamp = datetime.fromisoformat(entry['collected_at'].replace('Z', '+00:00'))
if stamp.utcoffset() is None: raise ValueError('Record timezone-aware collection time')
if type(entry.get('http_status')) is not int or entry['http_status'] != 200:
    raise ValueError('HTTP failure: preserve the response and keep the previous state')
source = (manifest.parent / entry['response_file']).resolve()
raw = source.read_bytes()
response = json.loads(raw)
if not isinstance(response, dict) or response.get('status') != 'succeeded' or response.get('action') != action or response.get('error') is not None:
    raise ValueError('Unsuccessful account response; state must not advance')
request_id = response.get('request_id')
if not isinstance(request_id, str) or not request_id.strip(): raise ValueError('Missing request_id')
data = response.get('data')
if not isinstance(data, dict) or not isinstance(data.get('timeline'), list):
    raise ValueError('Expected the complete direct data.timeline array')
old = None
seen = set()
old_requests = []
if previous != '-':
    old = json.loads(Path(previous).read_text(encoding='utf-8'))
    if not isinstance(old, dict) or old.get('version') != 1 or old.get('screen_name') != scope or not isinstance(old.get('seen_ids'), list) or not isinstance(old.get('request_ids'), list):
        raise ValueError('State belongs to another workflow or account')
    def identifier(value): return isinstance(value, str) and value.isascii() and value.isdigit() and any(c != '0' for c in value)
    if any(not identifier(v) for v in old['seen_ids']) or len(old['seen_ids']) != len(set(old['seen_ids'])):
        raise ValueError('Invalid seen-ID state')
    old_requests = old['request_ids']
    if any(not isinstance(v, str) or not v.strip() for v in old_requests) or len(old_requests) != len(set(old_requests)):
        raise ValueError('Invalid request history')
    last = datetime.fromisoformat(old['last_collected_at'].replace('Z', '+00:00'))
    if last.utcoffset() is None or stamp <= last or request_id in old_requests:
        raise ValueError('Use a later new observation, not a replay or reordered response')
    seen = set(old['seen_ids'])
rows, page_ids, duplicates = [], set(), 0
metrics = ['favorites', 'retweets', 'replies', 'quotes', 'bookmarks', 'views']
def count(value):
    if value is None: return ''
    if type(value) is int and 0 <= value <= 9007199254740991: return value
    if isinstance(value, str) and value.isascii() and value.isdigit(): return value
    raise ValueError('Expected a nonnegative safe integer or original digit string counter')
for post in data['timeline']:
    if not isinstance(post, dict): raise ValueError('Unexpected timeline item')
    key = post.get('tweet_id')
    if not isinstance(key, str) or not key.isascii() or not key.isdigit() or not any(c != '0' for c in key):
        raise ValueError('Original string tweet_id required; numeric IDs cannot be repaired')
    author = post.get('author')
    if author is not None and not isinstance(author, dict): raise ValueError('Invalid author object')
    author_id = (author or {}).get('rest_id')
    if author_id is not None and (not isinstance(author_id, str) or not author_id.isascii() or not author_id.isdigit()):
        raise ValueError('Preserve original string author rest_id')
    for field in ['text', 'created_at', 'lang', 'reply_to']:
        if post.get(field) is not None and not isinstance(post[field], str): raise ValueError('Unexpected text field')
    state = 'baseline' if old is None else ('seen_before' if key in seen else 'newly_observed')
    row = {'tweet_id': key, 'status': state, 'requested_screen_name': handle, 'author_rest_id': author_id,
        'text': post.get('text'), 'created_at': post.get('created_at'), 'lang': post.get('lang'),
        'reply_to': post.get('reply_to'), 'has_retweeted_object': post.get('retweeted_tweet') is not None,
        'collected_at': entry['collected_at'], 'request_id': request_id}
    row.update({k: count(post.get(k)) for k in metrics})
    if key in page_ids:
        duplicates += 1
        continue
    page_ids.add(key)
    rows.append(row)
cursor = data.get('next_cursor')
if cursor is not None and not isinstance(cursor, str): raise ValueError('Unexpected next_cursor type')
next_cursor = cursor if cursor and cursor.strip() else None
new_rows = [row for row in rows if row['status'] == 'newly_observed']
state = {'version': 1, 'screen_name': scope, 'seen_ids': sorted(seen | page_ids),
    'request_ids': old_requests + [request_id], 'last_collected_at': entry['collected_at']}
report = {'mode': 'baseline' if old is None else 'compare', 'screen_name': handle,
    'returned_items': len(data['timeline']), 'unique_ids_this_page': len(page_ids), 'duplicates_this_page': duplicates,
    'newly_observed': len(new_rows), 'previous_ids_not_on_this_page': len(seen - page_ids),
    'source_file': str(source), 'source_sha256': hashlib.sha256(raw).hexdigest(),
    'request_id': request_id, 'collected_at': entry['collected_at'], 'next_cursor': next_cursor,
    'coverage': 'first page only; no claim of all posts since the previous run',
    'pinned_saved_separately': 'pinned' in data, 'network_calls': 0}
output = Path(output)
output.mkdir(parents=False, exist_ok=False)
def cell(value):
    if value is None: return ''
    value = str(value)
    return "'" + value if value.lstrip().startswith(('=', '+', '-', '@')) else value
columns = ['tweet_id', 'status', 'requested_screen_name', 'author_rest_id', 'text', 'created_at', 'lang', 'reply_to', 'has_retweeted_object'] + metrics + ['collected_at', 'request_id']
for filename, selected in [('observed-posts.csv', rows), ('new-posts.csv', new_rows)]:
    with (output / filename).open('x', encoding='utf-8-sig', newline='') as f:
        writer = csv.writer(f); writer.writerow(columns)
        writer.writerows([[cell(row.get(k)) for k in columns] for row in selected])
(output / 'raw-response.json').write_bytes(raw)
for filename, value in [('state.json', state), ('coverage.json', report), ('profile.json', data.get('user')), ('pinned.json', data.get('pinned'))]:
    (output / filename).write_text(json.dumps(value, ensure_ascii=False, indent=2) + '\n', encoding='utf-8')
if next_cursor and page_ids:
    (output / 'backfill-request.json').write_text(json.dumps({'action': action, 'params': {'screen_name': handle, 'cursor': next_cursor}}, indent=2) + '\n', encoding='utf-8')
print(json.dumps({'mode': report['mode'], 'newly_observed': len(new_rows), 'output': str(output)}))
```

`watch_account.py` 只在本地处理。创建输出前，脚本检查账号范围、时间先后、请求重放、字符串 ID、报告的计数和响应结构。同一 ID 的点赞数变化不算新帖子。当前页每个不同的 ID 都写入 `observed-posts.csv`；同一页里重复的 ID 只保留第一行，`raw-response.json` 保留全部原始观察。

## 4. 正确解释交付文件

* `new-posts.csv`：相对历史状态新出现的编号，不等于“昨天之后发布”。平台重新展示的旧帖也可能第一次出现。
* `observed-posts.csv`：当前页的 baseline/seen_before/newly_observed 分类，文案、报告的发布时间、互动数与查询来源；缺值留空，0保留为0。
* `profile.json`、`pinned.json`：分别保存 `data.user` 和 `data.pinned` 的原对象。已观测合同里，timeline 的作者姓名和 `screen_name` 为空，脚本不会用请求的账号名填作者列。转推涉及其他人的原作，`has_retweeted_object` 标明转推的原作对象存在，完整内容仍在原始 JSON 里。
* `coverage.json`：当前页的条数、原文件哈希和续页游标。以前见过、这一页没出现的 ID 不会被标为已删除。哈希用于发现已保存原文件的变化，不能证明账号身份，也不是防篡改的完整历史。
* `state.json`：这个账号名历次见过的帖子 ID 和已接受的请求号。账号改名或名称被重新使用时，重新核对并建立新基线；`watch_account.py` 不会自行验证账号所有权的连续性。

置顶帖不会因为置顶就进入新增清单；同一个 ID 也出现在 timeline 里时，按正常去重处理。作者字段、浏览量或正文缺失时，不填猜测值。

## 5. 记录遗漏与继续分页的边界

每次新的监测都从不带 cursor 的账号首页开始，不要把昨天的游标当成今天的起点。也不能遇到第一个旧 ID 就停止处理本页：置顶或混合排序会让旧帖子排在新帖子前面。

活跃账号每天只取一页，可能会漏帖。`watch_account.py` 保存 `next_cursor`，并在本页非空时生成 `backfill-request.json`。`backfill-request.json` 是一个待批准预算的历史下一页请求，脚本不会自动发送。回填的历史结果另存为一组采集；`watch_account.py` 拒绝带 cursor 的请求，防止历史页悄悄变成下一次日常检查点。不能漏掉重要动态时，提高已批准的查询频率，或另建历史回填流程。没有游标或返回空页，都不能证明已覆盖全部历史。

## 6. 交付可行动的摘要

1. 人工核对 `new-posts.csv` 里的相关变化，给每条补上值得关注的理由。
2. 用保留的 ID 组成链接 `https://x.com/i/status/<tweet_id>`。
3. 摘要聚焦公开的商业活动，不记录个人行踪，也不推测私密属性。
4. 在摘要里注明账号、查询时间、不同帖子数和抽样范围。

`watch_account.py` 不会把摘要发给团队，也不开启周期性付费查询；这两项需要另行配置。

接受新的 `state.json` 前，抽两行与 `raw-response.json` 对照，再看 `coverage.json`。修改展示或重新导出已存文件不增加查询费用。依据：`twitter.web.fetch_user_post_tweet` 的已发布输出结构；示例中的账号占位符请替换为实际目标公开账号。

[关键词搜索](/zh/guides/x-search-posts) · [品牌讨论归类](/zh/guides/x-brand-mentions) · [X 问题](/zh/faq/x)