npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

n8n-nodes-douyin-video-crawler

v1.0.0

Published

抖音视频爬虫 n8n 节点 - 搜索、提取和下载抖音视频

Readme

n8n-nodes-douyin-video-crawler

抖音视频爬虫 n8n 社区节点 - 根据关键词搜索、提取和下载抖音短视频

功能特性

  • 🔍 关键词搜索: 根据关键词搜索抖音视频
  • 🎯 多维度筛选: 支持排序方式、发布时间、视频时长、搜索范围筛选
  • 📊 详细信息提取: 提取视频标题、作者、点赞数、评论数、分享数等完整信息
  • 💾 视频下载: 支持批量下载视频到本地,优先下载高清版本
  • 🛡️ 反爬虫处理: 内置反爬虫策略,包括随机延迟、User-Agent轮换等
  • 🔐 灵活认证: 支持Cookie认证或自动登录两种方式
  • ⚙️ 高度可配置: 丰富的高级选项,满足不同需求

安装

通过 n8n Community Nodes

  1. 在 n8n 中进入 Settings > Community Nodes
  2. 点击 Install a community node
  3. 输入 n8n-nodes-douyin-video-crawler
  4. 点击 Install

手动安装

cd ~/.n8n/nodes
npm install n8n-nodes-douyin-video-crawler

重启 n8n 后节点将可用。

使用说明

1. 配置凭据(可选)

虽然可以游客模式访问,但建议配置认证以获得更好的效果:

方式A: Cookie认证(推荐)

  1. 在 n8n 中创建新的 "Douyin API" 凭据
  2. 选择认证方式: Cookie(推荐)
  3. 获取Cookie:
    • 访问 抖音网站
    • 登录你的账号
    • 打开浏览器开发者工具(F12)
    • 进入 Application > Cookies > https://www.douyin.com
    • 复制所有Cookie值,格式: name1=value1; name2=value2; ...
  4. 将Cookie粘贴到凭据配置中

方式B: 自动登录

  1. 选择认证方式: 自动登录
  2. 输入手机号和密码
  3. 首次运行时可能需要手动验证

2. 配置节点参数

基础参数

  • 搜索关键词: 要搜索的视频关键词(必填)
  • 排序方式: 综合排序 / 最新发布 / 最多点赞
  • 发布时间: 不限 / 一天内 / 一周内 / 半年内
  • 视频时长: 不限 / 1分钟以下 / 1-5分钟 / 5分钟以上
  • 搜索范围: 不限 / 关注的人 / 最近看过 / 还未看过
  • 视频数量: 要爬取的视频数量(必须是4的倍数,如 12、16、20、24等)
  • 是否下载视频: 是否将视频下载到本地
  • 下载路径: 视频保存目录(默认: D:\KK_Movies\douyin

高级选项

  • 浏览器无头模式: 是否在后台运行浏览器(默认: 是)
  • 隐身模式: 启用反爬虫检测隐身模式(默认: 是)
  • 滚动延迟: 滚动加载视频时的等待时间(默认: 2000ms)
  • 每12视频间隔: 每爬取12个视频后的随机延迟范围(默认: 1-3秒)
  • 视频质量: 高清(优先)/ 标清 / 自动(默认: 高清)
  • 下载超时: 单个视频下载的最大等待时间(默认: 300秒)
  • 并发下载数: 同时下载的视频数量(默认: 3,范围: 1-5)
  • 重试次数: 下载失败时的重试次数(默认: 3次)
  • 调试模式: 启用详细的调试日志输出
  • 截图保存: 保存页面截图用于调试

3. 输出数据格式

每个视频作为独立的输出项,包含以下信息:

{
  "videoId": "7123456789",
  "title": "视频标题",
  "author": "作者名称",
  "authorId": "MS4wLjAB...",
  "videoUrl": "https://...",
  "coverUrl": "https://...",
  "duration": 45,
  "likeCount": 12345,
  "commentCount": 678,
  "shareCount": 234,
  "viewCount": 567890,
  "publishTime": "2024-01-15",
  "crawledTime": "2024-01-20T10:30:00.000Z",
  "downloaded": true,
  "downloadPath": "D:\\KK_Movies\\douyin\\作者_标题_20240120.mp4",
  "fileName": "作者_标题_20240120.mp4",
  "fileSize": 12345678,
  "hashtags": ["#话题1", "#话题2"],
  "description": "视频描述",
  "_metadata": {
    "totalVideos": 12,
    "downloadedVideos": 12,
    "failedVideos": 0,
    "executionTime": 120000,
    "searchKeywords": "AI智能体",
    "filters": {...}
  }
}

使用示例

示例1: 搜索并下载视频

搜索关键词: "AI智能体"
排序方式: 最多点赞
视频数量: 12
是否下载: 是
下载路径: D:\KK_Movies\douyin

示例2: 只提取视频信息不下载

搜索关键词: "美食推荐"
发布时间: 一周内
视频时长: 1-5分钟
视频数量: 20
是否下载: 否

注意事项

⚠️ 重要提示:

  1. 视频数量限制: 视频数量必须是4的倍数(如 12、16、20、24等)
  2. 反爬虫机制: 请遵守延迟设置,避免被封禁
  3. 合法使用: 请确保遵守抖音平台的使用条款
  4. 仅供学习: 本插件仅用于学习和研究目的,请勿用于商业用途
  5. Cookie有效期: Cookie可能过期,需要定期更新
  6. 资源消耗: 使用Puppeteer会消耗较多系统资源

故障排除

问题1: Cookie认证失败

解决方案:

  • 确认Cookie格式正确(name=value; name2=value2
  • 检查Cookie是否过期,重新获取
  • 尝试使用自动登录方式

问题2: 浏览器启动失败

解决方案:

  • 确保系统已安装 Chromium/Chrome
  • 检查系统资源是否充足
  • 尝试禁用无头模式进行调试

问题3: 视频下载失败

解决方案:

  • 检查网络连接
  • 增加下载超时时间
  • 确认下载路径有写入权限
  • 检查磁盘空间是否充足

问题4: 找不到视频元素

解决方案:

  • 抖音页面结构可能发生变化
  • 启用调试模式和截图功能查看页面状态
  • 联系开发者更新选择器

开发

构建项目

npm install
npm run build

开发模式

npm run dev

代码格式化

npm run format

代码检查

npm run lint
npm run lintfix

技术架构

本插件使用以下技术:

  • Puppeteer: 浏览器自动化
  • puppeteer-extra-plugin-stealth: 反爬虫检测
  • axios: HTTP请求和文件下载
  • TypeScript: 类型安全的开发

模块结构

  • PuppeteerManager: 浏览器管理
  • AuthManager: 认证管理(Cookie/自动登录)
  • SearchManager: 搜索和筛选
  • VideoExtractor: 视频信息提取
  • VideoDownloader: 视频下载
  • AntiScraping: 反爬虫策略

更新日志

v1.0.0 (2024-01-20)

  • 首次发布
  • 支持关键词搜索和多维度筛选
  • 支持Cookie和自动登录两种认证方式
  • 支持批量下载视频(优选高清)
  • 内置反爬虫策略
  • 文件命名格式: {author}_{title}_{date}.mp4

许可证

MIT

支持

如有问题或建议,请提交 Issue。

免责声明

本插件仅供学习和研究使用。使用本插件时,请遵守抖音平台的服务条款和相关法律法规。开发者不对使用本插件导致的任何后果负责。