# twscrape 常见报错排查：404、No account available、XClIdParseError、ct0 和封号

twscrape 的故障基本归为四类：X 改版网页脚本导致 `x-client-transaction-id` 失效（`SearchTimeline` 报 404、`XClIdParseError` 或全池账号被锁 15 分钟）、登录流程拿不到 `ct0` Cookie、账号因“不真实行为”被封（GraphQL 返回空 404 但 `UserByScreenName` 仍 200），以及翻页截断（粉丝列表提前停、`tweet_replies` 只拿到约 10 条）。排查前先升级版本并用真浏览器确认账号还活着；不想再养 Cookie 账号池的话，用 XTikAPI 不用 X 账号，一次 $0.002。

更新于 2026-11-25

## 报错对照表：一眼定位原因和修法

| 报错或现象 | issue 里定位的原因 | 有效处理办法 |
| --- | --- | --- |
| `No account available for queue SearchTimeline` + `Failed to parse scripts` | X 改网页脚本导致解析失败，账号池全部被锁 15 分钟（issue 298、49） | 升级 twscrape 后执行 `twscrape reset_locks` |
| `SearchTimeline` / `UserTweetsAndReplies` 报 `Unhandled API response code: 404` | 缺少或过期的 `x-client-transaction-id` 请求头（issue 248、245、322） | 升级到 v0.17.0 以上（每次 X 改 JS 包都要跟着升级） |
| `XClIdParseError: X web scripts not found` | 2026 年 8 月 X 把脚本分块哈希从 7 位改为 16 位（issue 330） | 升到 v0.20.1 以上（有用户确认 87 个号全部恢复） |
| GraphQL 空 404 + `AbortReqError: Failed to get XClIdGen` + `verify_credentials.json` 报 401 code 32 | 账号因 inauthentic behavior 被封，2026 年 11 月起新号首次跑也可能被封（issue 384） | 用浏览器登录确认是否封号；只能换号 |
| `ct0 not in cookies (most likely ip ban)` | 登录流程走完但 X 没下发 CSRF Cookie `ct0`（issue 214） | 先用浏览器手动登录，等约 15 分钟，删掉账号后直接带浏览器 Cookie 重新添加 |
| `api.followers()` / `api.following()` 拉不全提前停 | 旧版把“空页但带游标”当结束（issue 265、247）；另外 X 本身可能截断关注列表 | 升级到 v0.18.0 以上；对照主页粉丝数核验 |
| `api.tweet_replies(twid, limit=-1)` 只拿 8–10 条 | twscrape 只跟 `Bottom` 游标，漏掉 `ShowMoreThreads` 等折叠游标（issue 215，未关） | 本地修改游标处理逻辑，或换能跟全游标的接口 |

## 如果继续用 twscrape，建议这样排查

1. 怪代码前先用正常浏览器登录其中一个报错账号。2026 年 11 月起（issue 384），被封号在 `SearchTimeline` 返回空 404 而 `UserByScreenName` 仍 200，twscrape 会误判成交易 ID 问题并报 `Failed to get XClIdGen`。
2. 尽量不要走 twscrape 自带的自动登录，改用浏览器导出 Cookie 添加账号（先 `twscrape del_accounts <用户名>` 再重新添加），能避开大部分 `ct0 not in cookies`（issue 214）。
3. 遇到全池同时报 404 或 `XClIdParseError`，优先看最新版 release（v0.17.0 引入交易 ID、v0.18.0 修复粉丝提前停止、v0.20.1 修复 16 位脚本哈希）。
4. 无论用哪个工具抓回复，要还原嵌套层级都按 `inReplyToTweetId` 和 `conversationId` 重建（issue 114）。

## 不想维护账号池和交易 ID 的替代方案

当 Cookie 账号变成消耗品、X 一改前端脚本就停工时，直接调托管只读接口会省心很多：

1. 搜推文：`x.posts.search` 传 `keyword`（支持 `from:`、`since:` 等搜索语法）、`search_type` 和 `cursor`。
2. 用户推文与资料：`x.posts.list` 和 `x.accounts.detail` 传 `screen_name`。
3. 推文回复与粉丝列表：`x.comments.list` 传推文 `id`；`x.accounts.followers` / `x.accounts.following` 传 `screen_name` 和 `cursor`。

费用估算：每天盯 20 个关键词 × 10 页、连续 30 天 = 6000 次 × $0.002 = $12；拉一个 2 万粉丝账号（约 20 人/页）≈ 1000 次 = $2。失败不收费。

## 为什么用 XTikAPI

- XTikAPI 有 16 个X（推特）接口，一次 $0.002 起，失败不收费。
- 更省 Token：按 2026-11-18 实测的 10 个X（推特）接口真实返回，平台原始 JSON 约 63k token，经 XTikAPI 归一化后约 21k token（省 66.7%），MCP 输出约 23k token（省 63.7%）。
- 先看再用：229 个接口里有 192 个在接口页上放了一份录制的真实返回（X（推特） 10/16），字段一目了然。
- 花钱可控：失败和超时不收费，返回里写着 charged: false；X-Max-Price 限定一次最多花多少，同一个 Idempotency-Key 24 小时内不重复扣费。
- 免费试用：验证过邮箱送 $0.50，不用绑卡。

## 用到的接口

- [X（推特）推文搜索](https://xtikapi.com/zh/apis/x/posts/search) ($0.002 / 次): 按搜索词取一页推文。
- [X（推特）用户推文](https://xtikapi.com/zh/apis/x/posts/list) ($0.002 / 次): 按用户名取一个账号的推文，从新到旧。
- [X（推特）用户资料](https://xtikapi.com/zh/apis/x/accounts/detail) ($0.002 / 次): 按用户名取公开主页：简介、粉丝数、推文数。
- [X（推特）推文回复](https://xtikapi.com/zh/apis/x/comments/list) ($0.002 / 次): 取一条推文下的回复。
- [X（推特）粉丝列表](https://xtikapi.com/zh/apis/x/accounts/followers) ($0.002 / 次): 按用户名取一页粉丝，`cursor` 翻页。
- [X（推特）关注列表](https://xtikapi.com/zh/apis/x/accounts/following) ($0.002 / 次): 按用户名取一页他关注的账号，`cursor` 翻页。

## X（推特）的更多问题

- [X（推特） API](https://xtikapi.com/zh/apis/x)
- [twikit 常见报错与限流指南：Cloudflare 403、KEY_BYTE、登录 399 与封号](https://xtikapi.com/zh/answers/twikit-errors-and-fixes)
- [2026 年用 X（推特）API 读推文要多少钱，有更便宜的办法吗](https://xtikapi.com/zh/answers/x-api-pricing-alternative)
- [Agent Reach 推特（X）渠道用不了怎么办](https://xtikapi.com/zh/answers/agent-reach-twitter-channel-broken)
- [怎么获取 X（推特）账号的粉丝列表，频率限制是多少](https://xtikapi.com/zh/answers/x-api-followers-list-rate-limit)
- [采集社交平台的公开数据合法吗](https://xtikapi.com/zh/answers/is-scraping-public-social-media-data-legal)

## 怎么做

- [用 Python 获取 X（推特）用户的推文](https://xtikapi.com/zh/guides/x-user-posts-python)

## 出处

本页写到的别家的情况，都来自对方自己的页面和文档，读取于 2026-11-25。

- [twscrape issue 384：账号因 inauthentic behavior 被封，表现为 404](https://github.com/vladkens/twscrape/issues/384)
- [twscrape issue 330：XClIdParseError: X web scripts not found](https://github.com/vladkens/twscrape/issues/330)
- [twscrape issue 298：No account available for queue SearchTimeline](https://github.com/vladkens/twscrape/issues/298)
- [twscrape issue 248：SearchTimeline 报 404](https://github.com/vladkens/twscrape/issues/248)
- [twscrape issue 214：ct0 not in cookies](https://github.com/vladkens/twscrape/issues/214)
- [twscrape issue 265：粉丝列表迭代提前停止](https://github.com/vladkens/twscrape/issues/265)
- [twscrape issue 215：tweet_replies 最多只抓到 10 条](https://github.com/vladkens/twscrape/issues/215)
- [X API 官方文档：频率限制](https://docs.x.com/x-api/fundamentals/rate-limits)

## 常见问题

### `twscrape reset_locks` 能修好 No account available 吗？

仅在账号正常、临时波动导致锁定时有效。如果是脚本解析坏了或账号被封，解锁后会立刻再次锁死。

### SearchTimeline 返回 404 是被限流了吗？

不是。限流返回 HTTP 429；GraphQL 404 在 twscrape 里通常是 `x-client-transaction-id` 被拒，或者账号已被封。

### 为什么 `tweet_replies` 设了 `limit=-1` 还是只给 10 条？

`limit=-1` 只取消 twscrape 自己的条数上限，它不会继续跟 X 返回的 `ShowMoreThreads` 类游标，所以翻页会提前结束（issue 215）。

---

XTikAPI: one API key for public social media data, prepaid per call. [HTML version](https://xtikapi.com/zh/answers/twscrape-errors-and-fixes) · [llms.txt](https://xtikapi.com/llms.txt) · [OpenAPI](https://xtikapi.com/openapi.json)
