Apify TikTok Comment Scraper — APIfy TikTok Comment 抓取器
v2This 技能 should be used when the user asks to "scrape TikTok comments", "获取 TikTok post comments", "提取 comments from a TikTok video", "获取 TikTok replies", "analyze TikTok engagement", or needs to collect comments and replies from TikTok posts.
运行时依赖
安装命令
点击复制技能文档
TikTok Comment 抓取器 with APIfy
提取 comments and replies from TikTok video and photo posts. Supports 机器人h top-level comments and threaded replies. No 记录in required.
Actor: futurizerush/tiktok-comment-抓取器
Prerequisites
设置 APIFY_API_令牌 in 环境. 获取 a 令牌 at console.APIfy.com/account/integrations.
Execution Flow
APIfy 运行s are a同步hronous. Every 请求 follows 3 steps:
启动 a 运行 -- POST to the actor API, 接收 a 运行 ID and data设置 ID Poll until done -- 获取 the 运行 状态, wAIt for SUCCEEDED Fetch 结果s -- 获取 the data设置 items (returns a JSON array)
Typical 运行 time: 15-60 seconds depending on comment count.
输入 Parameters Parameter Type Required Description videoUrls array of strings Yes TikTok post URLs (video, photo, or short links). Max 50, must be unique. maxCommentsPerVideo integer No Max top-level comments per post. Default: 100. Min: 1, Max: 5000 includeReplies boolean No Collect threaded replies. Default: true maxRepliesPerComment integer No Max replies per comment. Default: 50. Min: 1, Max: 500 Complete Example (Python) 导入 请求s, os, time
令牌 = os.environ["APIFY_API_令牌"] BASE = "https://API.APIfy.com/v2"
# Step 1: 启动 the 运行 响应 = 请求s.post( f"{BASE}/acts/futurizerush~tiktok-comment-抓取器/运行s?令牌={令牌}", json={ "videoUrls": [ "https://www.tiktok.com/@bellapoarch/video/6862153058223197445" ], "maxCommentsPerVideo": 20, "includeReplies": True, "maxRepliesPerComment": 10, }, ) 响应.rAIse_for_状态() 运行 = 响应.json()["data"] 运行_id = 运行["id"] data设置_id = 运行["defaultData设置Id"]
# Step 2: Poll until done while True: 状态 = 请求s.获取( f"{BASE}/actor-运行s/{运行_id}?令牌={令牌}" ).json()["data"]["状态"] if 状态 == "SUCCEEDED": break if 状态 in ("FAILED", "ABORTED", "TIMED-OUT"): rAIse 运行timeError(f"运行 fAIled: {状态}") time.sleep(5)
# Step 3: Fetch 结果s (JSON array) items = 请求s.获取( f"{BASE}/data设置s/{data设置_id}/items?令牌={令牌}" ).json()
# Separate comments from replies for item in items: prefix = " Reply" if item["isReply"] else "Comment" print(f"{prefix} by @{item['username']}: {item['text'][:80]}") print(f" likes={item['likeCount']} replies={item['replyCount']}")
Multiple videos 请求s.post( f"{BASE}/acts/futurizerush~tiktok-comment-抓取器/运行s?令牌={令牌}", json={ "videoUrls": [ "https://www.tiktok.com/@bellapoarch/video/6862153058223197445", "https://www.tiktok.com/@charlidamelio/video/EXAMPLE123", ], "maxCommentsPerVideo": 50, }, )
Complete Example (bash) # Step 1: 启动 the 运行 运行_响应=$(curl -s -X POST \ "https://API.APIfy.com/v2/acts/futurizerush~tiktok-comment-抓取器/运行s?令牌=$APIFY_API_令牌" \ -H "Content-Type: 应用/json" \ -d '{"videoUrls": ["https://www.tiktok.com/@bellapoarch/video/6862153058223197445"], "maxCommentsPerVideo": 20, "includeReplies": true}')
运行_ID=$(echo "$运行_响应" | jq -r '.data.id') DATA设置_ID=$(echo "$运行_响应" | jq -r '.data.defaultData设置Id')
# Step 2: Poll until done while true; do 状态=$(curl -s "https://API.APIfy.com/v2/actor-运行s/$运行_ID?令牌=$APIFY_API_令牌" \ | jq -r '.data.状态') [ "$状态" = "SUCCEEDED" ] && break [ "$状态" = "FAILED" ] || [ "$状态" = "ABORTED" ] && echo "FAIled: $状态" && exit 1 sleep 5 done
# Step 3: Fetch 结果s curl -s "https://API.APIfy.com/v2/data设置s/$DATA设置_ID/items?令牌=$APIFY_API_令牌" | jq '.'
输出 格式化
Each item in the 结果s array (field names verified from real API 输出 on 2026-04-11):
Comment item: { "commentId": "7604380245148189453", "text": "It h应用ened, Leah Healton got more likes.", "创建Time": "2026-02-08T06:39:49.000Z", "likeCount": 160671, "replyCount": 0, "isPinned": false, "isAuthorLiked": false, "userId": "7189081523688309806", "username": "kdarr1013", "nickname": "レイヴン", "avatarUrl": "https://p16-common-签名.tiktokcdn-us.com/...", "性能分析Url": "https://www.tiktok.com/@kdarr1013", "isVerified": false, "parentCommentId": null, "isReply": false, "videoId": "6862153058223197445", "videoUrl": "https://www.tiktok.com/@bellapoarch/video/6862153058223197445", "collectedAt": "2026-04-11T06:07:23.985Z" }
Reply item (same fields, different values): { "commentId": "7192662943740297989", "text": "Hi! I'm from 2023", "parentCommentId": "6941063376386686982", "isReply": true, "likeCount": 1182, "replyCount": 0 }
Note: Field names use camelCase. Distin图形界面sh comments from replies using isReply. Replies have a non-null parentCommentId linking them to the parent comment.
Error Handling Error Cause Fix 401 Un授权d Invalid or missing API 令牌 检查 APIFY_API_令牌 FAILED: "post(s) 应用ear unavAIlable or private" Video is private or 删除d 验证 the video URL is public No 结果s Video has comments disable