scraping-twitter-profiles

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Scraping Twitter Profiles

抓取Twitter个人资料

Bulk profile data export for any set of Twitter/X usernames. Returns account-level metadata: follower counts, bios, join dates, verification status.
批量导出任意Twitter/X用户名集合的个人资料数据。返回账号级元数据:粉丝数、简介、注册日期、认证状态。

Prerequisites

前提条件

  • APIFY_TOKEN
    environment variable set
  • Optional: Apify MCP server installed
  • 设置
    APIFY_TOKEN
    环境变量
  • 可选:安装Apify MCP服务器

Inputs

输入参数

ParameterTypeRequiredDefaultNotes
startUrls
arrayOptional
[]
Twitter profile or tweet URLs
twitterHandles
arrayOptional
[]
Twitter usernames (without @)
twitterUserIds
arrayOptional
[]
Twitter user IDs
getFollowers
booleanOptional
false
Extract follower lists
getFollowing
booleanOptional
false
Extract following lists
getRetweeters
booleanOptional
false
Extract retweeters of a tweet URL
includeUnavailableUsers
booleanOptional
false
Include unavailable/suspended users
maxItems
numberOptionalUnlimitedMaximum users to return
customMapFunction
stringOptionalJavaScript function to transform each output object
参数类型是否必填默认值说明
startUrls
array可选
[]
Twitter个人资料或推文URL
twitterHandles
array可选
[]
Twitter用户名(不带@)
twitterUserIds
array可选
[]
Twitter用户ID
getFollowers
boolean可选
false
提取粉丝列表
getFollowing
boolean可选
false
提取关注列表
getRetweeters
boolean可选
false
提取推文URL的转发者
includeUnavailableUsers
boolean可选
false
包含不可用/被封禁的用户
maxItems
number可选无限制返回的最大用户数量
customMapFunction
string可选用于转换每个输出对象的JavaScript函数

Workflow

工作流程

Progress:
- [ ] Step 1: Normalize username list
- [ ] Step 2: Run twitter-user-scraper
- [ ] Step 3: Poll for SUCCEEDED
- [ ] Step 4: Deliver profile dataset
进度:
- [ ] 步骤1:标准化用户名列表
- [ ] 步骤2:运行twitter-user-scraper
- [ ] 步骤3:轮询直到状态为SUCCEEDED
- [ ] 步骤4:交付个人资料数据集

Step 1: Normalize

步骤1:标准化

Remove
@
symbols, deduplicate, validate no empty strings.
移除
@
符号,去重,验证无空字符串。

Step 2: Run the Actor

步骤2:运行Actor

Recommended — run_actor.js (handles waiting, output, and file saving automatically):
bash
undefined
推荐方式 — run_actor.js(自动处理等待、输出和文件保存):
bash
undefined

Quick answer (prints table to chat)

快速输出(在聊天中打印表格)

node scripts/run_actor.js
--actor "apidojo~twitter-user-scraper"
--input '{"param": "value"}'
node scripts/run_actor.js
--actor "apidojo~twitter-user-scraper"
--input '{"param": "value"}'

Save as CSV

保存为CSV

node scripts/run_actor.js
--actor "apidojo~twitter-user-scraper"
--input '{"param": "value"}'
--output YYYY-MM-DD_results.csv --format csv
node scripts/run_actor.js
--actor "apidojo~twitter-user-scraper"
--input '{"param": "value"}'
--output YYYY-MM-DD_results.csv --format csv

Save as JSON

保存为JSON

node scripts/run_actor.js
--actor "apidojo~twitter-user-scraper"
--input '{"param": "value"}'
--output YYYY-MM-DD_results.json --format json
> `APIFY_TOKEN` must be set in environment or `.env` file.

**If Apify MCP is available:**
Tool: apify:run-actor Actor: "apidojo~twitter-user-scraper" Input: { "usernames": ["handle1", "handle2", "handle3"] }

**REST API fallback:**
```bash
curl -X POST \
  "https://api.apify.com/v2/acts/apidojo~twitter-user-scraper/runs?token=$APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"usernames": ["handle1", "handle2"]}'
Save
id
as
RUN_ID
. Poll until
status = SUCCEEDED
:
bash
curl "https://api.apify.com/v2/actor-runs/$RUN_ID?token=$APIFY_TOKEN" | grep '"status"'
Fetch results:
bash
curl "https://api.apify.com/v2/actor-runs/$RUN_ID/dataset/items?token=$APIFY_TOKEN&format=json"
node scripts/run_actor.js
--actor "apidojo~twitter-user-scraper"
--input '{"param": "value"}'
--output YYYY-MM-DD_results.json --format json
> `APIFY_TOKEN` 必须在环境变量或`.env`文件中设置。

**如果Apify MCP可用:**
工具: apify:run-actor Actor: "apidojo~twitter-user-scraper" 输入: { "usernames": ["handle1", "handle2", "handle3"] }

**REST API备选方案:**
```bash
curl -X POST \
  "https://api.apify.com/v2/acts/apidojo~twitter-user-scraper/runs?token=$APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"usernames": ["handle1", "handle2"]}'
保存
id
RUN_ID
。轮询直到
status = SUCCEEDED
:
bash
curl "https://api.apify.com/v2/actor-runs/$RUN_ID?token=$APIFY_TOKEN" | grep '"status"'
获取结果:
bash
curl "https://api.apify.com/v2/actor-runs/$RUN_ID/dataset/items?token=$APIFY_TOKEN&format=json"

Step 3: Handle Edge Cases

步骤3:处理边缘情况

  • Missing accounts in results: Account suspended, deleted, or handle changed. Note missing handles in output.
  • Private accounts: Returns profile metadata but no tweet content — flag
    isPrivate: true
    rows.
  • Deactivated accounts: Returns null or empty object — exclude from final dataset.
  • 结果中缺少部分账号:账号被封禁、删除或用户名已更改。在输出中记录缺失的用户名。
  • 私有账号:返回个人资料元数据但无推文内容 — 标记
    isPrivate: true
    的行。
  • 已停用账号:返回null或空对象 — 从最终数据集中排除。

Output Format

输出格式

undefined
undefined

Twitter Profile Dataset

Twitter个人资料数据集

Accounts requested: N | Accounts returned: N | Missing: N
UsernameDisplay NameFollowersFollowingTweetsVerifiedBio (truncated)Joined
........................
Available fields: username, displayName, followersCount, followingCount, tweetCount, isVerified, isBlueVerified, description, location, url, profileImageUrl, createdAt, isPrivate
undefined
请求的账号数量: N | 返回的账号数量: N | 缺失数量: N
用户名显示名称粉丝数关注数推文数已认证简介(截断)注册日期
........................
可用字段: username, displayName, followersCount, followingCount, tweetCount, isVerified, isBlueVerified, description, location, url, profileImageUrl, createdAt, isPrivate
undefined

Troubleshooting

故障排除

Some handles missing from results: Accounts may be suspended or renamed — cross-reference manually. Large lists (> 1000): Break into batches of 500 and run sequentially.
部分用户名未出现在结果中:账号可能已被封禁或重命名 — 手动交叉验证。 大型列表(>1000个):拆分为500个一组,依次运行。