scraping-twitter-profile-tweets

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Scraping Twitter Profile Tweets

抓取Twitter主页推文

Raw data collection. No assumed use case — returns the full dataset for downstream analysis.

原始数据采集。不预设使用场景——返回完整数据集供下游分析。

Inputs

输入参数

ParameterTypeRequiredDefaultNotes
startUrls
arrayOptional
[]
Twitter profile URLs (x.com or twitter.com formats)
twitterHandles
arrayOptional
[]
Twitter usernames (without @)
start
stringOptionalTweets after this date (YYYY-MM-DD or YYYY-MM-DD_HH:MM:SS_UTC)
end
stringOptionalTweets before this date (YYYY-MM-DD or YYYY-MM-DD_HH:MM:SS_UTC)
includeNativeRetweets
booleanOptional
false
Include native retweets in results
onlyImages
booleanOptional
false
Only tweets containing images
getReplies
booleanOptional
false
Include tweet replies
minReplyCount
numberOptionalMinimum reply count threshold
getAboutData
booleanOptional
false
Fetch full profile about data
maxItems
numberOptionalUnlimitedMaximum tweets to return
customMapFunction
stringOptionalJavaScript function to transform each output object
参数类型是否必填默认值说明
startUrls
array可选
[]
Twitter主页URL(支持x.com或twitter.com格式)
twitterHandles
array可选
[]
Twitter用户名(不带@符号)
start
string可选在此日期之后发布的推文(格式为YYYY-MM-DD或YYYY-MM-DD_HH:MM:SS_UTC)
end
string可选在此日期之前发布的推文(格式为YYYY-MM-DD或YYYY-MM-DD_HH:MM:SS_UTC)
includeNativeRetweets
boolean可选
false
结果中包含原生转发推文
onlyImages
boolean可选
false
仅返回包含图片的推文
getReplies
boolean可选
false
包含推文回复
minReplyCount
number可选最低回复数量阈值
getAboutData
boolean可选
false
获取完整的主页简介数据
maxItems
number可选无限制返回的最大推文数量
customMapFunction
string可选用于转换每个输出对象的JavaScript函数

How to Run

运行方式

Using run_actor.js (recommended)

使用run_actor.js(推荐)

bash
undefined
bash
undefined

Quick answer (table)

快速返回(表格形式)

node scripts/run_actor.js --actor "apidojo~twitter-profile-scraper" --input '{"twitterHandles": ["elonmusk"], "maxItems": 100}'
node scripts/run_actor.js --actor "apidojo~twitter-profile-scraper" --input '{"twitterHandles": ["elonmusk"], "maxItems": 100}'

Save as CSV

保存为CSV格式

node scripts/run_actor.js --actor "apidojo~twitter-profile-scraper" --input '{"twitterHandles": ["elonmusk"], "maxItems": 100}' --output results.csv --format csv
node scripts/run_actor.js --actor "apidojo~twitter-profile-scraper" --input '{"twitterHandles": ["elonmusk"], "maxItems": 100}' --output results.csv --format csv

Save as JSON

保存为JSON格式

node scripts/run_actor.js --actor "apidojo~twitter-profile-scraper" --input '{"twitterHandles": ["elonmusk"], "maxItems": 100}' --output results.json --format json
undefined
node scripts/run_actor.js --actor "apidojo~twitter-profile-scraper" --input '{"twitterHandles": ["elonmusk"], "maxItems": 100}' --output results.json --format json
undefined

REST API fallback

备用REST API方式

bash
curl -X POST "https://api.apify.com/v2/acts/apidojo~twitter-profile-scraper/runs" \
  -H "Authorization: Bearer $APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"twitterHandles": ["elonmusk"], "maxItems": 100}'
If Apify MCP is available: Use the Apify MCP
call_actor
tool with actor
apidojo~twitter-profile-scraper
and the input above.

bash
curl -X POST "https://api.apify.com/v2/acts/apidojo~twitter-profile-scraper/runs" \
  -H "Authorization: Bearer $APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"twitterHandles": ["elonmusk"], "maxItems": 100}'
若Apify MCP可用: 使用Apify MCP的
call_actor
工具,指定actor为
apidojo~twitter-profile-scraper
并传入上述输入参数。

Output Fields

输出字段

FieldTypeDescription
type
stringAlways
tweet
id
stringTweet ID
url
stringTweet URL (x.com)
twitterUrl
stringTweet URL (twitter.com)
text
stringTweet text content
retweetCount
numberRetweet count
replyCount
numberReply count
likeCount
numberLike count
quoteCount
numberQuote tweet count
bookmarkCount
numberBookmark count
createdAt
stringCreation timestamp
lang
stringDetected language
isReply
booleanWhether this is a reply
isRetweet
booleanWhether this is a retweet
isQuote
booleanWhether this is a quote tweet
source
stringTwitter client used
author.userName
stringAuthor @username
author.name
stringAuthor display name
author.isVerified
booleanLegacy verification
author.isBlueVerified
booleanTwitter Blue verification
author.profilePicture
stringAuthor profile picture URL
author.followers
numberAuthor follower count
字段类型描述
type
string固定为
tweet
id
string推文ID
url
string推文URL(x.com格式)
twitterUrl
string推文URL(twitter.com格式)
text
string推文文本内容
retweetCount
number转发数
replyCount
number回复数
likeCount
number点赞数
quoteCount
number引用推文数
bookmarkCount
number收藏数
createdAt
string创建时间戳
lang
string检测到的语言
isReply
boolean是否为回复推文
isRetweet
boolean是否为转发推文
isQuote
boolean是否为引用推文
source
string使用的Twitter客户端
author.userName
string作者@用户名
author.name
string作者显示名称
author.isVerified
boolean传统认证标识
author.isBlueVerified
booleanTwitter Blue认证标识
author.profilePicture
string作者头像URL
author.followers
number作者粉丝数

Edge Cases

边缘情况

  • Private account: Returns 0 tweets. Tell user the account is private.
  • Account suspended: Returns error. Handle may be banned.
  • Very active account: Use maxItems to cap and control cost ($0.0004 per extra tweet).
  • Date range: Minimum 50 results needed for the query to run. If few tweets in range, widen date range.
  • Retweets in results: Actor returns all public tweets including retweets.
  • 私人账号:返回0条推文。需告知用户该账号为私人账号。
  • 账号被封禁:返回错误信息。该账号可能已被封禁。
  • 高活跃度账号:使用maxItems参数限制返回数量,控制成本(每额外一条推文收费0.0004美元)。
  • 日期范围:查询需至少返回50条结果才能运行。若指定范围内推文数量较少,请扩大日期范围。
  • 结果中的转发推文:该工具会返回所有公开推文,包括转发内容。