by Pluviobyte
抓取抖音单条视频完整评论区(一级 + 楼中楼)的 Agent Skill:在已登录的 Chrome 里照抄页面真实请求,签名交给页面 SDK
# Add to your Claude Code skills
git clone https://github.com/Pluviobyte/douyin-commentsGuides for using ai agents skills like douyin-comments.
See how douyin-comments compares with popular alternatives.
douyin-comments is an open-source ai agents skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by Pluviobyte. 抓取抖音单条视频完整评论区(一级 + 楼中楼)的 Agent Skill:在已登录的 Chrome 里照抄页面真实请求,签名交给页面 SDK. It has 76 GitHub stars.
douyin-comments's catalog security scan is still queued. You can run an instant dependency and prompt-injection check now with the "Scan for vulnerabilities" button above.
Clone the repository with "git clone https://github.com/Pluviobyte/douyin-comments" and add it to your Claude Code skills directory (see the Installation section above). douyin-comments ships a SKILL.md manifest, so compatible agents can discover and load it automatically.
douyin-comments is primarily written in JavaScript. It is open-source under Pluviobyte on GitHub, so you can review or fork the full source.
Yes. SkillsLLM lists many other AI Agents skills you can browse and compare side by side. Open the AI Agents category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh douyin-comments against similar tools.
No comments yet. Be the first to share your thoughts!
Available after the catalog security scan passes.
⚠️ Third-Party Software Notice
This skill is third-party open-source software developed and hosted independently on GitHub. SkillsLLM is an informational directory and does not control or maintain the underlying repository.
Any security checks, ratings, or warnings displayed by SkillsLLM are automated and limited in scope. They do not constitute a security certification or guarantee that the software is safe, error-free, or free from malicious code, vulnerabilities, compromised dependencies, or prompt-injection risks.
Review the source code, permissions, dependencies, and configuration before installing or running any third-party skill. Use is at your own risk. To the maximum extent permitted by applicable law, SkillsLLM is not liable for losses arising from third-party software.
The deep catalog scan for this skill is still queued. Run an instant dependency check now instead.
device_platform/aid 直接调楼中楼接口,会立刻弹文字点选验证码,请求挂起(2026-10-30 实测)。原因是缺了页面正常请求才有的公共参数(channel、version_code、浏览器信息、msToken 等)。所以:
page_fetch.js:先拦截页面自己发出的一次真实评论请求当模板,之后只替换 aweme_id / cursor / comment_id,其余参数照抄。page_ui_expand.js:在评论区逐个点「展开N条回复」,由页面自己发请求,我们只截获响应。慢,但实测不触发风控。.internal/抖音评论/<aweme_id>/。源链接、作者、原文评论只留在 .internal/;给成稿用的归纳文件不写源信息。window.__dyc 上轮询,数据经本地接收服务落盘。下文 $SK = 本 skill 目录,$OUT = 输出目录。
douyin.com/video/<id> → id;主页链接带 modal_id=<id> → id;v.douyin.com/… 短链先在 Chrome 打开,看跳转后的 URL。run_in_background,端口被占就换一个,并在页面设 window.__DYC_RECV):
python3 -I "$SK/scripts/recv.py" --out "$OUT/raw" --port 8765
tabs_context_mcp → tabs_create_mcp 新开标签页 → navigate 到 https://www.douyin.com/video/<id>。扩展未连接时,请用户在 Claude Code 里执行 /chrome 连接。page_hook.js 的全文(读文件后原样传入),返回 hooked。刷新或跳转页面后必须重新注入。window.__DYC_UI_MAX = 1,执行 page_ui_expand.js,让页面真实展开一个楼,拿到楼中楼模板。不做的话,主路线会用一级模板派生。Object.keys(window.__dyc.templates).join(','),至少要有 top。不要在 javascript_tool 里打印模板 URL:带 Cookie 和查询串的输出会被工具拦截。要看参数,读 $OUT/raw/template_top.json。window.__DYC_CFG = { awemeId: '<id>' }; // 可选 skipDetail: true;skipThreads: [已抓全的 cid]
然后执行 page_fetch.js 全文。每 20~40 秒用一次 browser_batch(几个 10 秒 wait + 一次 javascript_tool 读 JSON.stringify(window.__dyc))轮询,同时看 $OUT/raw/_recv.log 的增长。耗时大约是:总请求数 × 3 秒。
done → 进入第 5 步fallback → 先截图。有验证码就请用户手动过,再走第 4 步;没有验证码,说明这一页返回为空或被拒(看 reason),也走第 4 步need_template → 回到第 2 步第 3 小步,让评论区加载出来page_hook.js → 点开评论区。page_ui_expand.js(不设 __DYC_UI_MAX)。状态 ui_captcha 表示又弹了验证码:请用户手动过,脚本会自动继续。ui_done 后进入第 5 步。主路线和兜底路线的数据会自动合并去重。python3 -I "$SK/scripts/build_report.py" "$OUT"
python3 -I "$SK/scripts/download_video.py" "$OUT"(720p,带 Referer,不需要 Cookie)。转写用本机 mlx_whisper;看画面就抽帧拼联系表直接看图,不要跑 OCR。评论全文.md,按「质疑 / 疑问 / 对比 / 使用经验」归类,归纳文件放在项目根目录,不写源信息。| 日期 | 视频 | 路线 | 结果 |
|---|---|---|---|
| 2026-10-30 | 7 分钟 AI 工具视频,195 条评论 | 主路线,先展开 1 个楼拿模板 | 83 + 112 = 195,与此前 UI 兜底抓到的结果逐条一致;35 次请求,138 秒,无验证码 |
| 2026-10-30 | 46 分钟教程,135 条评论 | 主路线,楼中楼模板由一级模板派生 | 77 + 58 = 135;63 次请求,252 秒,无验证码;720p 视频下载正常 |
还没覆盖到的情况:单个楼超过 20 条回复的翻页;上千条评论的大视频;ui_captcha 状态的自动检测。遇到时把结果补进上表。
$OUT/
├── raw/ # 模板、每页原始响应、_recv.log(可删)
├── comments_top.json # 一级评论(去重)
├── comments_replies.json
├── 评论全文.md # 按点赞排序,楼中楼缩进在下面
└── 参考视频.mp4 # 可选
抓取抖音单条视频完整评论区的 Agent Skill。 抓取范围包括一级评论、全部楼中楼回复和视频详情,可选下载 720p 视频,最终输出一份按点赞排序的 评论全文.md 和原始 JSON。
请求在你自己已登录的 Chrome 页面里发出,签名交给页面自带的 SDK 计算。不需要 TikHub 之类的付费接口,不需要 Playwright,也不用逆向 a_bogus。
| 视频 | 抓到 | 视频显示评论数 | 请求 / 耗时 | 验证码 |
|---|---|---|---|---|
| 7 分钟 AI 工具视频 | 一级 83 + 回复 112 = 195 | 195 | 35 次 / 138 秒 | 无 |
| 46 分钟教程 | 一级 77 + 回复 58 = 135 | 135 | 63 次 / 252 秒 | 无 |
第一条与逐个手动点「展开回复」抓到的结果逐条比对,完全一致。手动方式用了约 6 分钟。
抖音 Web 评论接口要带 a_bogus、msToken、uifid 等风控参数。如果只带 device_platform 和 aid 去调楼中楼接口,会立刻弹出文字点选验证码,请求一直挂起。原因是缺少页面正常请求里都有的那 30 多个公共参数。
所以这个 skill 不自己拼参数,而是照抄页面的真实请求:
page_hook.js:拦截页面自己发出的第一次评论请求,把它的 URL 和请求头记成模板。page_fetch.js(主路线):之后每次请求只替换 aweme_id、cursor、comment_id 三个参数,其余照抄。请求从页面内的 XHR 发出,由页面 SDK 补上签名。page_ui_expand.js(兜底路线):在评论区逐个点「展开 N 条回复」,由页面自己发请求,脚本只截获响应。这条路线慢,但不会触发风控。recv.py:本机接收服务,页面把每一页响应 POST 到 127.0.0.1 落盘。build_report.py:合并去重,逐楼核对回复数有没有抓全,再生成 评论全文.md。请求节奏为每次间隔 2~4 秒,每 15 次额外停 8~15 秒。
/chrome)git clone https://github.com/Pluviobyte/douyin-comments.git ~/.claude/skills/douyin-comments
也可以放到项目的 .claude/skills/ 下。如果目标目录已存在,先检查里面的内容,不要直接覆盖。
在 Claude Code 里给一个抖音视频链接,并说明要抓评论:
抓一下这条视频的评论区 https://www.douyin.com/video/7xxxxxxxxxxxxxxxxxx
支持三种链接:douyin.com/video/<id>、带 modal_id=<id> 的主页链接,以及 v.douyin.com 短链。
产出默认写到当前项目的 .internal/抖音评论/<aweme_id>/:
raw/ # 模板、每页原始响应、接收日志
comments_top.json # 一级评论(去重)
comments_replies.json # 楼中楼回复(去重)
评论全文.md # 按点赞排序,回复缩进在所属评论下面
参考视频.mp4 # 可选
完整流程见 SKILL.md。
整体思路参考了 MediaCrawler:公共参数集、uifid 请求头、先抓一级评论再逐楼抓回复、请求间留间隔。本仓库没有使用它的代码。