您的 scrape-detail 任务已经成功创建:
Task ID: e1a6f4ca-a9c9-49bb-be87-dd374cb24a40
Platform: tiktok
Action: scrape-detail
Target: https://www.tiktok.com/@zachking
Status: pending
浏览器扩展会:
-
轮询任务(每 30 秒)
GET /api/v1/scraping/tasks/pending -
发现您的任务
{ "id": "e1a6f4ca-a9c9-49bb-be87-dd374cb24a40", "platformId": "tiktok", "action": "scrape-detail", "target": {"url": "https://www.tiktok.com/@zachking"} } -
标记任务为处理中
POST /api/v1/scraping/tasks/e1a6f4ca.../start status: pending → processing -
等待您导航到 TikTok
- 扩展会检测到您在
tiktok.com域名上 - 会检查 URL 是否匹配任务目标
- 扩展会检测到您在
-
注入 scraper 脚本
chrome.scripting.executeScript({ target: { tabId }, files: ['dist/content/tiktok/scrape.js'] })
-
执行数据提取
- 提取 profile 数据
- 提取视频列表
- 提取详细信息
-
提交结果
POST /api/v1/scraping/tasks/e1a6f4ca.../result status: processing → completed
- 确保浏览器扩展已加载(chrome://extensions/)
- 打开 TikTok profile:
https://www.tiktok.com/@zachking - 等待几秒钟
- 扩展会自动处理并提交结果
如果想手动触发抓取:
-
打开 TikTok profile:
https://www.tiktok.com/@zachking -
打开 DevTools (F12)
-
在 Console 中执行:
// 获取任务 fetch('http://localhost:4000/api/v1/scraping/tasks/pending', { headers: {'X-API-Key': 'sk-test-integration-1234567890'} }).then(r => r.json()).then(d => { const task = d.tasks[0]; console.log('Task:', task); // 标记为处理中 return fetch(`http://localhost:4000/api/v1/scraping/tasks/${task.id}/start`, { method: 'POST', headers: {'X-API-Key': 'sk-test-integration-1234567890'} }); }).then(() => alert('Task started! Now the scraper can execute.'));
-
执行 scraper:
// 提取 profile 数据 const profile = await extractProfileData(); console.log('Profile:', profile);
-
提交结果:
const result = { taskId: 'e1a6f4ca-a9c9-49bb-be87-dd374cb24a40', platformId: 'tiktok', success: true, data: { items: [...] }, timestamp: new Date().toISOString() }; fetch(`http://localhost:4000/api/v1/scraping/tasks/e1a6f4ca.../result`, { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-API-Key': 'sk-test-integration-1234567890' }, body: JSON.stringify(result) });
- 打开: http://localhost:4000/admin.html
- 点击 "📊 Results" 标签
- 查看最新的抓取结果
curl http://localhost:4000/api/v1/scraping/results \
-H "X-API-Key: sk-test-integration-1234567890"curl http://localhost:4000/api/v1/scraping/tasks/e1a6f4ca-a9c9-49bb-be87-dd374cb24a40 \
-H "X-API-Key: sk-test-integration-1234567890"curl http://localhost:4000/api/v1/scraping/tasks/pending \
-H "X-API-Key: sk-test-integration-1234567890"输出:
{
"tasks": [
{
"id": "...",
"platformId": "tiktok",
"action": "scrape-detail",
"target": {"url": "https://www.tiktok.com/@realjayllnn"},
"status": "pending"
},
{
"id": "e1a6f4ca-a9c9-49bb-be87-dd374cb24a40",
"platformId": "tiktok",
"action": "scrape-detail",
"target": {"url": "https://www.tiktok.com/@zachking"},
"status": "pending"
}
],
"count": 2
}检查扩展是否运行:
- 打开
chrome://extensions/ - 找到 "Multi-Platform Scraper"
- 点击 "检查视图" (Service Worker 旁边)
- 查看 Console
预期日志:
🔍 Checking for pending tasks...
📥 Found 2 pending task(s)
如果您想自动化测试整个流程:
# 运行完整的测试(会打开浏览器并自动抓取)
node test-tiktok-full-flow.js这个脚本会:
- 创建任务
- 启动浏览器
- 导航到 TikTok profile
- 执行 scraper
- 提交结果
- 验证完成
- 目标: 抓取 profile 基本信息
- 数据: 用户名、显示名、简介、粉丝数、点赞数
- 适用: 批量抓取多个 KOL 的基本信息
- 目标: 抓取详细信息
- 数据:
- 完整 profile 信息
- 最新视频列表
- 视频统计(播放量、点赞数、评论数)
- 每个视频的详细信息
- 适用: 深度分析特定 KOL
当前的 TikTok scraper (scrapeTikTokProfile) 会:
- ✅ 提取 profile 基本信息
- ✅ 提取统计数据
- ✅ 提取播放列表
- ✅ 计算互动率
对于 scrape-detail,如果需要更详细的数据(如视频列表),可以扩展 scraper。
- 确保扩展已加载
- 访问: https://www.tiktok.com/@zachking
- 等待扩展自动处理
- 在 admin page 查看结果
- 访问: https://www.tiktok.com/@zachking
- 打开 DevTools (F12)
- 在 Console 中执行 scraper 代码
- 查看提取的数据
- 手动提交到 API
node test-tiktok-full-flow.js如果 scrape-detail 需要抓取视频列表等额外数据,我可以帮您扩展 scraper 功能。
最简单的方式:
- ✅ 确保浏览器扩展已加载并启用
- ✅ 打开浏览器访问: https://www.tiktok.com/@zachking
- ✅ 等待几秒让扩展处理
- ✅ 访问 http://localhost:4000/admin.html 查看结果
就这么简单!浏览器扩展会自动完成所有工作。
检查:
- 扩展是否已加载 (
chrome://extensions/) - API 服务器是否运行 (
lsof -ti:4000) - 扩展 Console 是否有错误
- 任务是否真的在队列中
可能原因:
- 扩展没有轮询到任务
- URL 不匹配
- Scraper 执行失败
解决: 查看扩展的 Service Worker Console (chrome://extensions/ → 检查视图)
您想选择哪种方式?我可以帮您:
- 测试扩展是否正常工作
- 手动执行 scraper 查看数据
- 运行自动化测试脚本
- 扩展 scraper 功能以支持更多数据