scraping-tiktok-user-data

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Scraping TikTok User Data

抓取TikTok用户数据

Exports a creator's full video history with per-video engagement metrics. Complements
scraping-tiktok-profile-data
(account-level) with video-level detail.
导出创作者的完整视频历史及每个视频的互动指标。作为
scraping-tiktok-profile-data
(账号级数据抓取)的补充,提供视频级的详细信息。

Prerequisites

前提条件

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

Inputs

输入参数

ParameterTypeRequiredDefaultNotes
startUrls
array
[]
TikTok profile URLs or video URLs (extracts author from videos)
getFollowers
booleanOptional
false
Also extract complete follower lists
getFollowing
booleanOptional
false
Also extract complete following lists
maxItems
numberOptionalUnlimitedMaximum users to return
customMapFunction
stringOptionalJavaScript function to transform each output object
参数类型是否必填默认值说明
startUrls
数组
[]
TikTok个人主页URL或视频URL(会从视频中提取作者信息)
getFollowers
布尔值可选
false
同时提取完整的粉丝列表
getFollowing
布尔值可选
false
同时提取完整的关注列表
maxItems
数字可选无限制返回的最大用户数量
customMapFunction
字符串可选用于转换每个输出对象的JavaScript函数

Workflow

工作流程

Progress:
- [ ] Step 1: Run tiktok-user-scraper
- [ ] Step 2: Poll for SUCCEEDED
- [ ] Step 3: Deliver video dataset
进度:
- [ ] 步骤1: 运行tiktok-user-scraper
- [ ] 步骤2: 轮询直至状态为SUCCEEDED
- [ ] 步骤3: 交付视频数据集

Step 1: Run the Actor

步骤1: 运行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~tiktok-user-scraper"
--input '{"param": "value"}'
node scripts/run_actor.js
--actor "apidojo~tiktok-user-scraper"
--input '{"param": "value"}'

Save as CSV

保存为CSV格式

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

Save as JSON

保存为JSON格式

node scripts/run_actor.js
--actor "apidojo~tiktok-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~tiktok-user-scraper" Input: { "username": "<handle>", "maxVideos": 50 }

**REST API fallback:**
```bash
curl -X POST \
  "https://api.apify.com/v2/acts/apidojo~tiktok-user-scraper/runs?token=$APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"username": "<handle>", "maxVideos": 50}'
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~tiktok-user-scraper"
--input '{"param": "value"}'
--output YYYY-MM-DD_results.json --format json
> 必须在环境变量或`.env`文件中设置`APIFY_TOKEN`。

**若Apify MCP可用:**
工具: apify:run-actor Actor: "apidojo~tiktok-user-scraper" 输入: { "username": "<handle>", "maxVideos": 50 }

**REST API备选方案:**
```bash
curl -X POST \
  "https://api.apify.com/v2/acts/apidojo~tiktok-user-scraper/runs?token=$APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"username": "<handle>", "maxVideos": 50}'
保存返回的
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 2: Handle Edge Cases

步骤2: 边缘情况处理

  • Private account: Returns 0 videos. Inform user.
  • Account with < requested videos: Return all available; note count in output.
  • Deleted videos in feed: Skip entries with missing
    playCount
    fields.
  • 私密账号: 返回0条视频。需告知用户。
  • 账号视频数量少于请求数量: 返回所有可用视频;在输出中注明实际数量。
  • 动态中存在已删除视频: 跳过缺少
    playCount
    字段的条目。

Output Format

输出格式

undefined
undefined

TikTok Video History: @<username>

TikTok视频历史: @<username>

Videos collected: N
Video IDCaption (truncated)ViewsLikesCommentsSharesDurationPosted
........................
Available fields: videoId, desc, playCount, diggCount, commentCount, shareCount, duration, createTime, videoUrl, musicTitle, hashtags
undefined
已收集视频数量: N
视频ID文案(截断)浏览量点赞数评论数分享数时长发布时间
........................
可用字段: videoId, desc, playCount, diggCount, commentCount, shareCount, duration, createTime, videoUrl, musicTitle, hashtags
undefined

Troubleshooting

故障排除

0 videos returned: Account is private or username incorrect. Pay-per-result billing: This actor uses pay-per-result pricing — set
maxVideos
to control cost.
返回0条视频: 账号为私密账号或用户名错误。 按结果计费: 该Actor采用按结果计费模式——设置
maxVideos
可控制成本。