用途
该技能用于从任意公开的 Twitter/X 列表(List)中导出全部成员的个人资料数据。适合用于整理行业精选名单、竞品观察清单,或获取现成的受众群体。
主要能力
- 抓取指定公开 Twitter/X 列表中的所有成员及其资料数据。
- 支持通过列表 URL(startUrls)或列表 ID(listIds)指定目标列表。
- 可通过 maxItems 限制返回的最大条目数。
- 可通过 customMapFunction 传入 JavaScript 函数,对每个输出对象进行转换。
- 输出格式支持在聊天中打印表格、保存为 CSV 或保存为 JSON。
使用方式
前置条件
- 设置 APIFY_TOKEN 环境变量。
- 可选:安装 Apify MCP 服务器。
输入参数
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| startUrls | array | 可选 | [] | Twitter 列表 URL(例如 https://x.com/i/lists/12345) |
| listIds | array | 可选 | [] | Twitter 列表 ID |
| maxItems | number | 可选 | 无限制 | 返回的最大推文数 |
| customMapFunction | string | 可选 | — | 用于转换每个输出对象的 JavaScript 函数 |
工作流程
- 验证列表 URL。
- 运行 twitter-list-scraper。
- 轮询直到状态为 SUCCEEDED。
- 交付成员数据集。
运行 Actor
推荐使用 run_actor.js(自动处理等待、输出和文件保存):
# 快速回答(在聊天中打印表格)
node scripts/run_actor.js \
--actor "apidojo~twitter-list-scraper" \
--input '{"param": "value"}'
# 保存为 CSV
node scripts/run_actor.js \
--actor "apidojo~twitter-list-scraper" \
--input '{"param": "value"}' \
--output YYYY-MM-DD_results.csv --format csv
# 保存为 JSON
node scripts/run_actor.js \
--actor "apidojo~twitter-list-scraper" \
--input '{"param": "value"}' \
--output YYYY-MM-DD_results.json --format json
APIFY_TOKEN 必须在环境变量或 .env 文件中设置。
如果 Apify MCP 可用:
- 工具:apify:run-actor
- Actor:"apidojo~twitter-list-scraper"
- 输入:
{
"listUrl": "https://twitter.com/i/lists/<LIST_ID>",
"maxItems": 500
}
REST API 备用方式:
curl -X POST \
"https://api.apify.com/v2/acts/apidojo~twitter-list-scraper/runs?token=$APIFY_TOKEN" \
-H "Content-Type: application/json" \
-d '{"listUrl": "https://twitter.com/i/lists/<LIST_ID>"}'
保存 id 为 RUN_ID。轮询直到 status = SUCCEEDED:
curl "https://api.apify.com/v2/actor-runs/$RUN_ID?token=$APIFY_TOKEN" | grep '"status"'
获取结果:
curl "https://api.apify.com/v2/actor-runs/$RUN_ID/dataset/items?token=$APIFY_TOKEN&format=json"
处理边界情况
- 私有列表:Actor 返回 0 条结果——告知用户该列表不可公开访问。
- 列表被删除或移动:在运行 actor 前验证 URL 返回 200。
- 超大列表(超过 5000 名成员):可能超时——使用 maxItems: 2000 并分页。
输出格式
# Twitter List Members: <list name>
List URL: <url> | Members collected: N
| Username | Display Name | Followers | Bio (truncated) | Location | Verified |
|----------|-------------|-----------|-----------------|----------|----------|
| ... | ... | ... | ... | ... | ... |
故障排除
- 0 条结果:列表为私有或 URL 格式错误。请确认列表是公开的。
- 部分结果:大列表可能受到速率限制——使用更小的 maxItems 重试。
适用场景
- 整理行业精选名单。
- 构建竞品观察清单。
- 获取现成的受众群体数据。
限制
- 仅支持公开的 Twitter/X 列表,私有列表无法抓取。
- 超大列表(超过 5000 名成员)可能超时,需要分页处理。
- 需要 APIFY_TOKEN 环境变量。
- 关于收费、价格、平台支持范围等更多信息暂未提供。