scraping-tiktok-comments
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseScraping TikTok Comments
抓取TikTok评论
Exports all comments from any TikTok video URL. Returns the raw comment dataset for sentiment analysis, community research, or product feedback extraction.
导出任意TikTok视频URL的所有评论。返回原始评论数据集,用于情感分析、社区研究或产品反馈提取。
Prerequisites
前提条件
- environment variable set
APIFY_TOKEN - Optional: Apify MCP server installed
- 已设置环境变量
APIFY_TOKEN - 可选:已安装Apify MCP服务器
Inputs
输入参数
| Parameter | Type | Required | Default | Notes |
|---|---|---|---|---|
| array | ✅ | | TikTok video URLs to scrape comments from |
| boolean | Optional | | Include reply comments (nested) |
| number | Optional | Unlimited | Maximum comments to return |
| string | Optional | — | JavaScript function to transform each output object |
| 参数 | 类型 | 是否必填 | 默认值 | 说明 |
|---|---|---|---|---|
| 数组 | ✅ | | 要抓取评论的TikTok视频URL |
| 布尔值 | 可选 | | 是否包含回复评论(嵌套评论) |
| 数字 | 可选 | 无限制 | 返回的最大评论数 |
| 字符串 | 可选 | — | 用于转换每个输出对象的JavaScript函数 |
Workflow
工作流程
Progress:
- [ ] Step 1: Validate video URLs
- [ ] Step 2: Run tiktok-comments-scraper
- [ ] Step 3: Poll for SUCCEEDED
- [ ] Step 4: Deliver comment datasetProgress:
- [ ] Step 1: Validate video URLs
- [ ] Step 2: Run tiktok-comments-scraper
- [ ] Step 3: Poll for SUCCEEDED
- [ ] Step 4: Deliver comment datasetStep 2: Run the Actor
步骤2:运行Actor
Recommended — run_actor.js (handles waiting, output, and file saving automatically):
bash
undefined推荐方式 — run_actor.js(自动处理等待、输出和文件保存):
bash
undefinedQuick answer (prints table to chat)
Quick answer (prints table to chat)
node scripts/run_actor.js
--actor "apidojo~tiktok-comments-scraper"
--input '{"param": "value"}'
--actor "apidojo~tiktok-comments-scraper"
--input '{"param": "value"}'
node scripts/run_actor.js
--actor "apidojo~tiktok-comments-scraper"
--input '{"param": "value"}'
--actor "apidojo~tiktok-comments-scraper"
--input '{"param": "value"}'
Save as CSV
Save as CSV
node scripts/run_actor.js
--actor "apidojo~tiktok-comments-scraper"
--input '{"param": "value"}'
--output YYYY-MM-DD_results.csv --format csv
--actor "apidojo~tiktok-comments-scraper"
--input '{"param": "value"}'
--output YYYY-MM-DD_results.csv --format csv
node scripts/run_actor.js
--actor "apidojo~tiktok-comments-scraper"
--input '{"param": "value"}'
--output YYYY-MM-DD_results.csv --format csv
--actor "apidojo~tiktok-comments-scraper"
--input '{"param": "value"}'
--output YYYY-MM-DD_results.csv --format csv
Save as JSON
Save as JSON
node scripts/run_actor.js
--actor "apidojo~tiktok-comments-scraper"
--input '{"param": "value"}'
--output YYYY-MM-DD_results.json --format json
--actor "apidojo~tiktok-comments-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~tiktok-comments-scraper"
Input:
{
"videoUrls": ["https://www.tiktok.com/@user/video/123456"],
"maxItems": 200,
"includeReplies": false
}
**REST API fallback:**
```bash
curl -X POST \
"https://api.apify.com/v2/acts/apidojo~tiktok-comments-scraper/runs?token=$APIFY_TOKEN" \
-H "Content-Type: application/json" \
-d '{"videoUrls": ["<url>"], "maxItems": 200}'Save as . Poll until :
idRUN_IDstatus = SUCCEEDEDbash
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~tiktok-comments-scraper"
--input '{"param": "value"}'
--output YYYY-MM-DD_results.json --format json
--actor "apidojo~tiktok-comments-scraper"
--input '{"param": "value"}'
--output YYYY-MM-DD_results.json --format json
> `APIFY_TOKEN`必须在环境变量或`.env`文件中设置。
**如果Apify MCP可用:**Tool: apify:run-actor
Actor: "apidojo~tiktok-comments-scraper"
Input:
{
"videoUrls": ["https://www.tiktok.com/@user/video/123456"],
"maxItems": 200,
"includeReplies": false
}
**REST API备选方案:**
```bash
curl -X POST \
"https://api.apify.com/v2/acts/apidojo~tiktok-comments-scraper/runs?token=$APIFY_TOKEN" \
-H "Content-Type: application/json" \
-d '{"videoUrls": ["<url>"], "maxItems": 200}'保存为。轮询直到:
idRUN_IDstatus = SUCCEEDEDbash
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:处理边缘情况
- 0 comments: Video may have comments disabled or be private. Report to user.
- Video deleted or unavailable: Actor returns error — remove URL from batch and notify.
- Comment count less than expected: TikTok filters spam comments server-side; this is expected.
- 0条评论:视频可能已禁用评论或为私有视频。需告知用户。
- 视频已删除或不可用:Actor返回错误 — 从批量任务中移除该URL并通知用户。
- 评论数少于预期:TikTok会在服务器端过滤垃圾评论;这属于正常情况。
Output Format
输出格式
undefinedundefinedTikTok Comment Dataset
TikTok Comment Dataset
Video: <url> | Comments collected: N | Includes replies: YES/NO
| Comment ID | Author | Text | Likes | Replies | Timestamp |
|---|---|---|---|---|---|
| ... | ... | ... | ... | ... | ... |
Available fields: id, text, authorUsername, diggCount, replyCount, createTime,
isReply, parentCommentId
undefinedVideo: <url> | Comments collected: N | Includes replies: YES/NO
| Comment ID | Author | Text | Likes | Replies | Timestamp |
|---|---|---|---|---|---|
| ... | ... | ... | ... | ... | ... |
Available fields: id, text, authorUsername, diggCount, replyCount, createTime,
isReply, parentCommentId
undefinedTroubleshooting
故障排除
Comments disabled: Creator has disabled comments — no workaround.
Truncated comments: Some comments may be cut off by TikTok's API; full text available via video page.
评论已禁用:创作者已禁用评论 — 无解决办法。
评论被截断:部分评论可能被TikTok的API截断;完整文本可通过视频页面查看。