Skill: yezi1985201/npdouyin-hot-trend (version 1.0.0)

--- name: douyin-hot-trend description: 获取抖音热榜/热搜榜数据，包含热门视频、挑战赛、音乐等多领域热门内容，并输出标题、热度值、跳转链接及封面图（如有）。 version: 1.1.0 --- # 抖音热榜 ## 技能概述 此技能用于抓取抖音热榜数据，包括： - 热点标题 - 热度值 - 详情跳转链接 - **封面图（如有）** ✅ 新增 - 热门标签 - 内容类型 ## 获取热榜 获取热榜（默认 50 条，按榜单顺序返回）： ```bash node scripts/douyin.js hot ``` 获取热榜前 N 条： ```bash node scripts/douyin.js hot 10 ``` ## 输出格式示例 ``` 🔥 抖音热榜 TOP 5 ====================================================================== 1. 国防部正告日方 🔥 热度: 11,849,702 🏷️ 标签: 3 🔗 链接: https://www.douyin.com/search/%E5%9B%BD%E9%98%B2%E9%83%A8%E6%AD%A3%E5%91%8A%E6%97%A5%E6%96%B9 2. 中国女篮81:68马里女篮 🔥 热度: 11,776,764 🏷️ 标签: 1 🔗 链接: https://www.douyin.com/search/%E4%B8%AD%E5%9B%BD%E5%A5%B3%E7%AF%AE81%3A68%E9%A9%AC%E9%87%8C%E5%A5%B3%E7%AF%AE ``` **注意：** 链接为纯文本 URL，可直接复制使用，无 HTML 标签包装。 ## 返回数据字段 | 字段 | 类型 | 说明 | |------|------|------| | rank | number | 榜单排名（从 1 开始） | | title | string | 热点标题 | | popularity | number | 热度值（HotValue，已转为数字；解析失败时为 0） | | link | string | 热点详情链接 | | **cover** | **string \| null** | **封面图 URL（新增）** | | label | string \| null | 标签/标识 | | type | string | 内容类型（视频、音乐、挑战赛等） | ## 版本更新日志 ### v1.1.0 (2025-02-27) - ✨ **新增封面图字段** - ✨ 优化数据输出格式 - ✨ 改进错误处理机制 ### v1.0.0 - 初始版本 - 支持基本热榜获取 ## 数据来源 抖音网页端公开接口 ## 注意事项 - 该接口为网页端公开接口，返回结构可能变动 - 访问频繁可能触发风控 - **封面图：** 并非所有热点都有封面图，部分条目可能为空

path: cron-job.js
content: #!/usr/bin/env node

/**
 * 抖音热榜定时任务 - OpenClaw 集成版本
 * 直接发送到 Telegram
 */

const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');

// 获取热榜数据
function getHotTrend(limit = 10) {
  try {
    const scriptPath = path.join(__dirname, 'scripts', 'douyin.js');
    const output = execSync(`node "${scriptPath}" hot ${limit}`, {
      encoding: 'utf-8',
      cwd: __dirname
    });
    return output;
  } catch (error) {
    console.error('获取抖音热榜失败:', error.message);
    return null;
  }
}

// 解析热榜数据
function parseHotTrend(output) {
  const lines = output.split('\n');
  const items = [];
  
  let currentItem = null;
  
  for (const line of lines) {
    // 匹配排名行
    const rankMatch = line.match(/^\s*(\d+)\.\s+(.+)/);
    if (rankMatch) {
      if (currentItem && currentItem.title) {
        items.push(currentItem);
      }
      currentItem = {
        rank: parseInt(rankMatch[1]),
        title: rankMatch[2].trim(),
        popularity: 0,
        link: '',
        label: null
      };
      continue;
    }
    
    // 匹配热度值
    if (currentItem && line.includes('热度:')) {
      const hotMatch = line.match(/热度:\s*([\d,]+)/);
      if (hotMatch) {
        currentItem.popularity = parseInt(hotMatch[1].replace(/,/g, ''));
      }
    }
    
    // 匹配链接
    if (currentItem && line.includes('链接:')) {
      const linkMatch = line.match(/链接:\s*(.+)/);
      if (linkMatch) {
        currentItem.link = linkMatch[1].trim();
      }
    }
    
    // 匹配标签
    if (currentItem && line.includes('标签:')) {
      const labelMatch = line.match(/标签:\s*(.+)/);
      if (labelMatch) {
        currentItem.label = labelMatch[1].trim();
      }
    }
  }
  
  if (currentItem && currentItem.title) {
    items.push(currentItem);
  }
  
  return items;
}

// 格式化 Telegram 消息
function formatTelegramMessage(items) {
  let message = '🔥 **抖音热榜 TOP ' + items.length + '**\n';
  message += '_每天下午6点自动推送_\n\n';
  
  for (const item of items) {
    const emoji = ['🥇', '🥈', '🥉'][item.rank - 1] || '🎯';
    message += `${emoji} *${item.rank}.* ${item.title}\n`;
    message += `   🔥 ${item.popularity.toLocaleString()}\n`;
    
    if (item.rank < 5) {
      // 前5名显示链接
      message += `   [查看详情](${item.link})\n`;
    }
    
    message += '\n';
  }
  
  message += '📱 _数据来源：抖音网页端_';
  message += '\n⏰ ' + new Date().toLocaleString('zh-CN', { 
    timeZone: 'Asia/Shanghai',
    year: 'numeric',
    month: '2-digit',
    day: '2-digit',
    hour: '2-digit',
    minute: '2-digit'
  });
  
  return message;
}

// 主函数
async function main() {
  const limit = 10;
  
  console.log('🎬 开始执行抖音热榜定时任务...');
  
  // 获取热榜数据
  const rawData = getHotTrend(limit);
  if (!rawData) {
    console.error('❌ 获取热榜数据失败');
    process.exit(1);
  }
  
  // 解析数据
  const items = parseHotTrend(rawData);
  console.log(`✅ 成功解析 ${items.length} 条热榜数据`);
  
  // 格式化消息
  const message = formatTelegramMessage(items);
  
  // 保存到文件（调试用）
  const outputFile = path.join(__dirname, 'daily-hot-trend-message.txt');
  fs.writeFileSync(outputFile, message, 'utf-8');
  
  // 输出 JSON（供 OpenClaw 消息工具使用）
  const jsonOutput = {
    success: true,
    timestamp: new Date().toISOString(),
    timezone: 'Asia/Shanghai',
    chat_id: '8428610733',
    channel: 'telegram',
    message: message,
    items: items.slice(0, limit),
    format: 'markdown'
  };
  
  const jsonFile = path.join(__dirname, 'daily-hot-trend-output.json');
  fs.writeFileSync(jsonFile, JSON.stringify(jsonOutput, null, 2), 'utf-8');
  
  console.log('📤 消息已准备发送到 Telegram');
  console.log(`💾 保存位置: ${jsonFile}`);
  
  // 输出消息内容（OpenClaw 会捕获）
  console.log('\n=== 消息预览 ===\n');
  console.log(message);
  
  return jsonOutput;
}

main().catch(error => {
  console.error('执行出错:', error);
  process.exit(1);
});


path: daily-hot-trend-message.txt
content: 🔥 **抖音热榜 TOP 10**
_每天下午6点自动推送_

🥇 *1.* 国防部正告日方
   🔥 12,094,236
   [查看详情](https://www.douyin.com/search/%E5%9B%BD%E9%98%B2%E9%83%A8%E6%AD%A3%E5%91%8A%E6%97%A5%E6%96%B9)

🥈 *2.* 中国造出“世界最强”碳纤维
   🔥 11,993,029
   [查看详情](https://www.douyin.com/search/%E4%B8%AD%E5%9B%BD%E9%80%A0%E5%87%BA%E2%80%9C%E4%B8%96%E7%95%8C%E6%9C%80%E5%BC%BA%E2%80%9D%E7%A2%B3%E7%BA%A4%E7%BB%B4)

🥉 *3.* 体验经济持续火爆
   🔥 11,950,960
   [查看详情](https://www.douyin.com/search/%E4%BD%93%E9%AA%8C%E7%BB%8F%E6%B5%8E%E6%8C%81%E7%BB%AD%E7%81%AB%E7%88%86)

🎯 *4.* 去机场不该比坐飞机时间还长
   🔥 11,871,691
   [查看详情](https://www.douyin.com/search/%E5%8E%BB%E6%9C%BA%E5%9C%BA%E4%B8%8D%E8%AF%A5%E6%AF%94%E5%9D%90%E9%A3%9E%E6%9C%BA%E6%97%B6%E9%97%B4%E8%BF%98%E9%95%BF)

🎯 *5.* 建议城市建立农民工子弟寄宿学校
   🔥 10,712,408

🎯 *6.* 全国两会第三场委员通道
   🔥 10,418,207

🎯 *7.* 建议AI应用设计多考虑残疾人
   🔥 9,136,507

🎯 *8.* 建议推行婴幼儿父母弹性上下班
   🔥 9,136,342

🎯 *9.* 制造业“马拉松”怎么跑
   🔥 9,110,599

🎯 *10.* 建议修改年休假天数规定
   🔥 9,102,688

📱 _数据来源：抖音网页端_
⏰ 2026/03/11 18:00

path: daily-hot-trend-output.json
content: {
  "success": true,
  "timestamp": "2026-03-11T10:00:03.316Z",
  "timezone": "Asia/Shanghai",
  "chat_id": "8428610733",
  "channel": "telegram",
  "message": "🔥 **抖音热榜 TOP 10**\n_每天下午6点自动推送_\n\n🥇 *1.* 国防部正告日方\n   🔥 12,094,236\n   [查看详情](https://www.douyin.com/search/%E5%9B%BD%E9%98%B2%E9%83%A8%E6%AD%A3%E5%91%8A%E6%97%A5%E6%96%B9)\n\n🥈 *2.* 中国造出“世界最强”碳纤维\n   🔥 11,993,029\n   [查看详情](https://www.douyin.com/search/%E4%B8%AD%E5%9B%BD%E9%80%A0%E5%87%BA%E2%80%9C%E4%B8%96%E7%95%8C%E6%9C%80%E5%BC%BA%E2%80%9D%E7%A2%B3%E7%BA%A4%E7%BB%B4)\n\n🥉 *3.* 体验经济持续火爆\n   🔥 11,950,960\n   [查看详情](https://www.douyin.com/search/%E4%BD%93%E9%AA%8C%E7%BB%8F%E6%B5%8E%E6%8C%81%E7%BB%AD%E7%81%AB%E7%88%86)\n\n🎯 *4.* 去机场不该比坐飞机时间还长\n   🔥 11,871,691\n   [查看详情](https://www.douyin.com/search/%E5%8E%BB%E6%9C%BA%E5%9C%BA%E4%B8%8D%E8%AF%A5%E6%AF%94%E5%9D%90%E9%A3%9E%E6%9C%BA%E6%97%B6%E9%97%B4%E8%BF%98%E9%95%BF)\n\n🎯 *5.* 建议城市建立农民工子弟寄宿学校\n   🔥 10,712,408\n\n🎯 *6.* 全国两会第三场委员通道\n   🔥 10,418,207\n\n🎯 *7.* 建议AI应用设计多考虑残疾人\n   🔥 9,136,507\n\n🎯 *8.* 建议推行婴幼儿父母弹性上下班\n   🔥 9,136,342\n\n🎯 *9.* 制造业“马拉松”怎么跑\n   🔥 9,110,599\n\n🎯 *10.* 建议修改年休假天数规定\n   🔥 9,102,688\n\n📱 _数据来源：抖音网页端_\n⏰ 2026/03/11 18:00",
  "items": [
    {
      "rank": 1,
      "title": "国防部正告日方",
      "popularity": 12094236,
      "link": "https://www.douyin.com/search/%E5%9B%BD%E9%98%B2%E9%83%A8%E6%AD%A3%E5%91%8A%E6%97%A5%E6%96%B9",
      "label": "1"
    },
    {
      "rank": 2,
      "title": "中国造出“世界最强”碳纤维",
      "popularity": 11993029,
      "link": "https://www.douyin.com/search/%E4%B8%AD%E5%9B%BD%E9%80%A0%E5%87%BA%E2%80%9C%E4%B8%96%E7%95%8C%E6%9C%80%E5%BC%BA%E2%80%9D%E7%A2%B3%E7%BA%A4%E7%BB%B4",
      "label": "3"
    },
    {
      "rank": 3,
      "title": "体验经济持续火爆",
      "popularity": 11950960,
      "link": "https://www.douyin.com/search/%E4%BD%93%E9%AA%8C%E7%BB%8F%E6%B5%8E%E6%8C%81%E7%BB%AD%E7%81%AB%E7%88%86",
      "label": "3"
    },
    {
      "rank": 4,
      "title": "去机场不该比坐飞机时间还长",
      "popularity": 11871691,
      "link": "https://www.douyin.com/search/%E5%8E%BB%E6%9C%BA%E5%9C%BA%E4%B8%8D%E8%AF%A5%E6%AF%94%E5%9D%90%E9%A3%9E%E6%9C%BA%E6%97%B6%E9%97%B4%E8%BF%98%E9%95%BF",
      "label": "3"
    },
    {
      "rank": 5,
      "title": "建议城市建立农民工子弟寄宿学校",
      "popularity": 10712408,
      "link": "https://www.douyin.com/search/%E5%BB%BA%E8%AE%AE%E5%9F%8E%E5%B8%82%E5%BB%BA%E7%AB%8B%E5%86%9C%E6%B0%91%E5%B7%A5%E5%AD%90%E5%BC%9F%E5%AF%84%E5%AE%BF%E5%AD%A6%E6%A0%A1",
      "label": "3"
    },
    {
      "rank": 6,
      "title": "全国两会第三场委员通道",
      "popularity": 10418207,
      "link": "https://www.douyin.com/search/%E5%85%A8%E5%9B%BD%E4%B8%A4%E4%BC%9A%E7%AC%AC%E4%B8%89%E5%9C%BA%E5%A7%94%E5%91%98%E9%80%9A%E9%81%93",
      "label": "3"
    },
    {
      "rank": 7,
      "title": "建议AI应用设计多考虑残疾人",
      "popularity": 9136507,
      "link": "https://www.douyin.com/search/%E5%BB%BA%E8%AE%AEAI%E5%BA%94%E7%94%A8%E8%AE%BE%E8%AE%A1%E5%A4%9A%E8%80%83%E8%99%91%E6%AE%8B%E7%96%BE%E4%BA%BA",
      "label": "3"
    },
    {
      "rank": 8,
      "title": "建议推行婴幼儿父母弹性上下班",
      "popularity": 9136342,
      "link": "https://www.douyin.com/search/%E5%BB%BA%E8%AE%AE%E6%8E%A8%E8%A1%8C%E5%A9%B4%E5%B9%BC%E5%84%BF%E7%88%B6%E6%AF%8D%E5%BC%B9%E6%80%A7%E4%B8%8A%E4%B8%8B%E7%8F%AD",
      "label": "3"
    },
    {
      "rank": 9,
      "title": "制造业“马拉松”怎么跑",
      "popularity": 9110599,
      "link": "https://www.douyin.com/search/%E5%88%B6%E9%80%A0%E4%B8%9A%E2%80%9C%E9%A9%AC%E6%8B%89%E6%9D%BE%E2%80%9D%E6%80%8E%E4%B9%88%E8%B7%91",
      "label": "3"
    },
    {
      "rank": 10,
      "title": "建议修改年休假天数规定",
      "popularity": 9102688,
      "link": "https://www.douyin.com/search/%E5%BB%BA%E8%AE%AE%E4%BF%AE%E6%94%B9%E5%B9%B4%E4%BC%91%E5%81%87%E5%A4%A9%E6%95%B0%E8%A7%84%E5%AE%9A",
      "label": "1"
    }
  ],
  "format": "markdown"
}

path: package-lock.json
content: {
  "name": "douyin-hot-trend",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "douyin-hot-trend",
      "version": "1.0.0",
      "license": "MIT"
    }
  }
}


path: package.json
content: {
  "name": "douyin-hot-trend",
  "version": "1.1.0",
  "description": "获取抖音热榜/热搜榜数据，包含热门视频、挑战赛、音乐等多领域热门内容",
  "keywords": [
    "douyin",
    "tiktok",
    "hot",
    "trend",
    "social",
    "chinese"
  ],
  "author": "franklu0819-lang",
  "license": "MIT",
  "openclaw": {
    "requires": {
      "bins": [
        "node"
      ]
    }
  }
}

path: README.md
content: # 抖音热榜获取技能

获取抖音热榜/热搜榜数据，包含热门视频、挑战赛、音乐等多领域热门内容，并输出标题、热度值与跳转链接。

## 功能特性

- 🔥 **实时热榜**: 获取抖音最新热门内容
- 📊 **热度值**: 显示每个话题的热度评分
- 🔗 **跳转链接**: 提供详情页直达链接
- 🎯 **自定义数量**: 可指定获取前 N 条数据
- 📱 **多领域内容**: 热门视频、挑战赛、音乐等

## 快速开始

```bash
# 获取抖音热榜前 50 条（默认）
node scripts/douyin.js hot

# 获取前 20 条
node scripts/douyin.js hot 20

# 获取前 10 条
node scripts/douyin.js hot 10
```

## 输出格式

每条热榜包含：
- 📌 **排名**: 热榜排名
- 🔥 **标题**: 热门话题/视频标题
- 📊 **热度值**: 热度评分
- 🔗 **链接**: 详情页跳转链接

## 使用示例

```bash
# 获取热门前 20
node scripts/douyin.js hot 20

# 输出示例：
# 1. 🔥 xxx话题
#    热度：1234567
#    链接：https://www.douyin.com/...
```

## 数据来源

抖音网页端公开接口

## 注意事项

- ⚠️ 该接口为网页端公开接口，返回结构可能变动
- ⚠️ 访问频繁可能触发风控
- ⚠️ 建议合理使用，避免频繁请求

## 使用场景

- 📰 热点追踪
- 📊 内容趋势分析
- 🎯 营销策划参考
- 📱 社交媒体运营

## Author

franklu0819-lang

## License

MIT


path: _meta.json
content: ownerId: kn784af36jyc12gczmcr7fq0a981dbhr
slug: douyin-hot-trend
version: 1.1.0
publishedAt: 1773252093299

path: scripts/douyin-with-cover.js
content: #!/usr/bin/env node

/**
 * 抖音热榜抓取脚本（增强版 - 带封面图）
 * 获取抖音热搜榜数据，并尝试获取封面图
 */

const https = require('https');

const USER_AGENTS = [
  'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
  'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
  'Mozilla/5.0 (Windows NT 10.0; Win64; x64) rv:121.0) Gecko/20100101 Firefox/121.0'
];

function getRandomUserAgent() {
  return USER_AGENTS[Math.floor(Math.random() * USER_AGENTS.length)];
}

function fetchDouyinHotBoard() {
  return new Promise((resolve, reject) => {
    const options = {
      hostname: 'www.douyin.com',
      path: '/aweme/v1/hot/search/list/',
      method: 'GET',
      headers: {
        'User-Agent': getRandomUserAgent(),
        'Accept': 'application/json',
        'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8',
        'Referer': 'https://www.douyin.com/'
      }
    };

    const req = https.request(options, (res) => {
      let data = '';

      res.on('data', (chunk) => {
        data += chunk;
      });

      res.on('end', () => {
        try {
          const jsonData = JSON.parse(data);
          resolve(jsonData);
        } catch (error) {
          reject(new Error(`JSON 解析失败: ${error.message}`));
        }
      });
    });

    req.on('error', (error) => {
      reject(error);
    });

    req.setTimeout(10000, () => {
      req.destroy();
      reject(new Error('请求超时'));
    });

    req.end();
  });
}

function formatHotBoard(data, limit = 50) {
  if (!data || !data.data || !data.data.word_list) {
    return [];
  }

  return data.data.word_list.slice(0, limit).map((item, index) => ({
    rank: index + 1,
    title: item.word || '无标题',
    popularity: item.hot_value || 0,
    link: item.url || `https://www.douyin.com/search/${encodeURIComponent(item.word || '')}`,
    cover: item.cover || null,
    label: item.label || null,
    type: item.type || '未知'
  }));
}

function printHotBoard(hotList) {
  console.log('🔥 抖音热榜 TOP ' + hotList.length);
  console.log('=' .repeat(70));
  console.log();

  hotList.forEach((item) => {
    console.log(`${item.rank.toString().padStart(2, ' ')}. ${item.title}`);
    console.log(`    🔥 热度: ${item.popularity.toLocaleString()}`);
    if (item.label) {
      console.log(`    🏷️ 标签: ${item.label}`);
    }
    if (item.cover) {
      console.log(`    🖼️  封面: ${item.cover}`);
    }
    console.log(`    🔗 链接: ${item.link}`);
    console.log();
  });
}

// 主函数
async function main() {
  const args = process.argv.slice(2);
  const command = args[0] || 'hot';
  const limit = parseInt(args[1]) || 50;

  if (command === 'hot') {
    try {
      console.log('正在获取抖音热榜...\n');
      const data = await fetchDouyinHotBoard();
      const hotList = formatHotBoard(data, limit);

      if (hotList.length === 0) {
        console.log('❌ 未获取到热榜数据');
        process.exit(1);
      }

      printHotBoard(hotList);
    } catch (error) {
      console.error(`❌ 获取热榜失败: ${error.message}`);
      process.exit(1);
    }
  } else {
    console.log('用法:');
    console.log('  node scripts/douyin.js hot [数量]');
    console.log('');
    console.log('示例:');
    console.log('  node scripts/douyin.js hot      # 获取热榜（默认50条）');
    console.log('  node scripts/douyin.js hot 20   # 获取热榜前20条');
    process.exit(1);
  }
}

main();


path: scripts/douyin.js
content: #!/usr/bin/env node

/**
 * 抖音热榜抓取脚本（增强版 - 带封面图）
 * 获取抖音热搜榜数据，并尝试获取封面图
 */

const https = require('https');

const USER_AGENTS = [
  'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
  'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
  'Mozilla/5.0 (Windows NT 10.0; Win64; x64) Gecko/20100101 Firefox/121.0'
];

function getRandomUserAgent() {
  return USER_AGENTS[Math.floor(Math.random() * USER_AGENTS.length)];
}

function fetchDouyinHotBoard() {
  return new Promise((resolve, reject) => {
    const options = {
      hostname: 'www.douyin.com',
      path: '/aweme/v1/hot/search/list/',
      method: 'GET',
      headers: {
        'User-Agent': getRandomUserAgent(),
        'Accept': 'application/json',
        'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8',
        'Referer': 'https://www.douyin.com/'
      }
    };

    const req = https.request(options, (res) => {
      let data = '';

      res.on('data', (chunk) => {
        data += chunk;
      });

      res.on('end', () => {
        try {
          const jsonData = JSON.parse(data);
          resolve(jsonData);
        } catch (error) {
          reject(new Error(`JSON 解析失败: ${error.message}`));
        }
      });
    });

    req.on('error', (error) => {
      reject(error);
    });

    req.setTimeout(10000, () => {
      req.destroy();
      reject(new Error('请求超时'));
    });

    req.end();
  });
}

function formatHotBoard(data, limit = 50) {
  if (!data || !data.data || !data.data.word_list) {
    return [];
  }

  return data.data.word_list.slice(0, limit).map((item, index) => ({
    rank: index + 1,
    title: item.word || '无标题',
    popularity: item.hot_value || 0,
    link: item.url || `https://www.douyin.com/search/${encodeURIComponent(item.word || '')}`,
    cover: item.cover || null,
    label: item.label || null,
    type: item.type || '未知'
  }));
}

function printHotBoard(hotList) {
  console.log('🔥 抖音热榜 TOP ' + hotList.length);
  console.log('=' .repeat(70));
  console.log();

  hotList.forEach((item) => {
    console.log(`${item.rank.toString().padStart(2, ' ')}. ${item.title}`);
    console.log(`    🔥 热度: ${item.popularity.toLocaleString()}`);
    if (item.label) {
      console.log(`    🏷️ 标签: ${item.label}`);
    }
    if (item.cover) {
      console.log(`    🖼️  封面: ${item.cover}`);
    }
    console.log(`    🔗 链接: ${item.link}`);
    console.log();
  });
}

// 主函数
async function main() {
  const args = process.argv.slice(2);
  const command = args[0] || 'hot';
  const limit = parseInt(args[1]) || 50;

  if (command === 'hot') {
    try {
      console.log('正在获取抖音热榜...\n');
      const data = await fetchDouyinHotBoard();
      const hotList = formatHotBoard(data, limit);

      if (hotList.length === 0) {
        console.log('❌ 未获取到热榜数据');
        process.exit(1);
      }

      printHotBoard(hotList);
    } catch (error) {
      console.error(`❌ 获取热榜失败: ${error.message}`);
      process.exit(1);
    }
  } else {
    console.log('用法:');
    console.log('  node scripts/douyin.js hot [数量]');
    console.log('');
    console.log('示例:');
    console.log('  node scripts/douyin.js hot      # 获取热榜（默认50条）');
    console.log('  node scripts/douyin.js hot 20   # 获取热榜前20条');
    process.exit(1);
  }
}

main();


path: scripts/get-hot-trend.js
content: #!/usr/bin/env node

/**
 * 抖音热榜定时任务脚本
 * 用于 OpenClaw cron 自动化
 */

const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');

// 获取热榜数据
function getHotTrend(limit = 10) {
  try {
    const scriptPath = path.join(__dirname, 'douyin.js');
    const output = execSync(`node "${scriptPath}" hot ${limit}`, {
      encoding: 'utf-8',
      cwd: path.dirname(scriptPath)
    });
    return output;
  } catch (error) {
    console.error('获取抖音热榜失败:', error.message);
    return null;
  }
}

// 格式化热榜消息
function formatMessage(hotTrendText) {
  const lines = hotTrendText.split('\n').filter(line => line.trim());
  
  let message = '🔥 **抖音热榜 TOP 10**\n';
  message += '=' .repeat(50) + '\n\n';
  
  let inList = false;
  let itemCount = 0;
  
  for (const line of lines) {
    // 跳过标题和分隔线
    if (line.includes('抖音热榜') || line.includes('===') || line.includes('正在获取')) {
      continue;
    }
    
    // 解析榜单条目
    if (line.match(/^\s*\d+\./)) {
      inList = true;
      itemCount++;
      if (itemCount > 10) break; // 只取前10
      
      // 提取排名和标题
      const match = line.match(/^\s*(\d+)\.\s*(.+)/);
      if (match) {
        const rank = match[1];
        const title = match[2].trim();
        message += `${rank}. ${title}\n`;
      }
    } else if (inList && line.includes('热度:')) {
      // 提取热度值
      const hotMatch = line.match(/热度:\s*([\d,]+)/);
      if (hotMatch) {
        message += `   🔥 ${hotMatch[1]}\n\n`;
      }
    }
  }
  
  message += '\n📱 数据来源：抖音网页端公开接口';
  message += '\n⏰ 更新时间：' + new Date().toLocaleString('zh-CN', { timeZone: 'Asia/Shanghai' });
  
  return message;
}

// 主函数
async function main() {
  const limit = process.argv[2] || 10;
  
  console.log('开始获取抖音热榜...');
  const hotTrendData = getHotTrend(limit);
  
  if (!hotTrendData) {
    console.error('❌ 获取热榜数据失败');
    process.exit(1);
  }
  
  const message = formatMessage(hotTrendData);
  
  // 输出到文件（用于调试）
  const outputFile = path.join(__dirname, 'latest-hot-trend.txt');
  fs.writeFileSync(outputFile, message, 'utf-8');
  
  // 输出到 stdout（OpenClaw 会捕获）
  console.log('\n=== 抖音热榜报告 ===\n');
  console.log(message);
  
  // 保存为 JSON 格式（供程序调用）
  const jsonOutput = {
    success: true,
    timestamp: new Date().toISOString(),
    timezone: 'Asia/Shanghai',
    message: message,
    rawData: hotTrendData
  };
  
  const jsonFile = path.join(__dirname, 'latest-hot-trend.json');
  fs.writeFileSync(jsonFile, JSON.stringify(jsonOutput, null, 2), 'utf-8');
  
  console.log('\n✅ 热榜数据已保存到:');
  console.log(`  - ${outputFile}`);
  console.log(`  - ${jsonFile}`);
}

main().catch(error => {
  console.error('执行出错:', error);
  process.exit(1);
});


path: scripts/latest-hot-trend.json
content: {
  "success": true,
  "timestamp": "2026-03-11T18:01:14.694Z",
  "timezone": "Asia/Shanghai",
  "message": "🔥 **抖音热榜 TOP 10**\n==================================================\n\n1. 国防部正告日方\n   🔥 11,860,886\n\n2. 麦基CBA生涯首秀\n   🔥 11,791,769\n\n3. “十五五”开局 国家把“人”放在C位\n   🔥 11,727,050\n\n4. 中国女篮81:68马里女篮\n   🔥 11,469,270\n\n5. 水庆霞代表为退役运动员发声\n   🔥 10,846,967\n\n6. CBA深圳新世纪88:96辽宁本钢\n   🔥 10,819,474\n\n7. 建议修改年休假天数规定\n   🔥 9,434,709\n\n8. 建议推行婴幼儿父母弹性上下班\n   🔥 9,336,524\n\n9. 从“投资于人”到“民生为大”\n   🔥 9,220,301\n\n10. 建议AI应用设计多考虑残疾人\n   🔥 9,145,796\n\n\n📱 数据来源：抖音网页端公开接口\n⏰ 更新时间：2026/3/12 02:01:14",
  "rawData": "正在获取抖音热榜...\n\n🔥 抖音热榜 TOP 10\n======================================================================\n\n 1. 国防部正告日方\n    🔥 热度: 11,860,886\n    🏷️ 标签: 3\n    🔗 链接: https://www.douyin.com/search/%E5%9B%BD%E9%98%B2%E9%83%A8%E6%AD%A3%E5%91%8A%E6%97%A5%E6%96%B9\n\n 2. 麦基CBA生涯首秀\n    🔥 热度: 11,791,769\n    🔗 链接: https://www.douyin.com/search/%E9%BA%A6%E5%9F%BACBA%E7%94%9F%E6%B6%AF%E9%A6%96%E7%A7%80\n\n 3. “十五五”开局 国家把“人”放在C位\n    🔥 热度: 11,727,050\n    🏷️ 标签: 3\n    🔗 链接: https://www.douyin.com/search/%E2%80%9C%E5%8D%81%E4%BA%94%E4%BA%94%E2%80%9D%E5%BC%80%E5%B1%80%20%E5%9B%BD%E5%AE%B6%E6%8A%8A%E2%80%9C%E4%BA%BA%E2%80%9D%E6%94%BE%E5%9C%A8C%E4%BD%8D\n\n 4. 中国女篮81:68马里女篮\n    🔥 热度: 11,469,270\n    🏷️ 标签: 3\n    🔗 链接: https://www.douyin.com/search/%E4%B8%AD%E5%9B%BD%E5%A5%B3%E7%AF%AE81%3A68%E9%A9%AC%E9%87%8C%E5%A5%B3%E7%AF%AE\n\n 5. 水庆霞代表为退役运动员发声\n    🔥 热度: 10,846,967\n    🔗 链接: https://www.douyin.com/search/%E6%B0%B4%E5%BA%86%E9%9C%9E%E4%BB%A3%E8%A1%A8%E4%B8%BA%E9%80%80%E5%BD%B9%E8%BF%90%E5%8A%A8%E5%91%98%E5%8F%91%E5%A3%B0\n\n 6. CBA深圳新世纪88:96辽宁本钢\n    🔥 热度: 10,819,474\n    🏷️ 标签: 3\n    🔗 链接: https://www.douyin.com/search/CBA%E6%B7%B1%E5%9C%B3%E6%96%B0%E4%B8%96%E7%BA%AA88%3A96%E8%BE%BD%E5%AE%81%E6%9C%AC%E9%92%A2\n\n 7. 建议修改年休假天数规定\n    🔥 热度: 9,434,709\n    🔗 链接: https://www.douyin.com/search/%E5%BB%BA%E8%AE%AE%E4%BF%AE%E6%94%B9%E5%B9%B4%E4%BC%91%E5%81%87%E5%A4%A9%E6%95%B0%E8%A7%84%E5%AE%9A\n\n 8. 建议推行婴幼儿父母弹性上下班\n    🔥 热度: 9,336,524\n    🔗 链接: https://www.douyin.com/search/%E5%BB%BA%E8%AE%AE%E6%8E%A8%E8%A1%8C%E5%A9%B4%E5%B9%BC%E5%84%BF%E7%88%B6%E6%AF%8D%E5%BC%B9%E6%80%A7%E4%B8%8A%E4%B8%8B%E7%8F%AD\n\n 9. 从“投资于人”到“民生为大”\n    🔥 热度: 9,220,301\n    🏷️ 标签: 3\n    🔗 链接: https://www.douyin.com/search/%E4%BB%8E%E2%80%9C%E6%8A%95%E8%B5%84%E4%BA%8E%E4%BA%BA%E2%80%9D%E5%88%B0%E2%80%9C%E6%B0%91%E7%94%9F%E4%B8%BA%E5%A4%A7%E2%80%9D\n\n10. 建议AI应用设计多考虑残疾人\n    🔥 热度: 9,145,796\n    🔗 链接: https://www.douyin.com/search/%E5%BB%BA%E8%AE%AEAI%E5%BA%94%E7%94%A8%E8%AE%BE%E8%AE%A1%E5%A4%9A%E8%80%83%E8%99%91%E6%AE%8B%E7%96%BE%E4%BA%BA\n\n"
}

path: scripts/latest-hot-trend.txt
content: 🔥 **抖音热榜 TOP 10**
==================================================

1. 国防部正告日方
   🔥 11,860,886

2. 麦基CBA生涯首秀
   🔥 11,791,769

3. “十五五”开局 国家把“人”放在C位
   🔥 11,727,050

4. 中国女篮81:68马里女篮
   🔥 11,469,270

5. 水庆霞代表为退役运动员发声
   🔥 10,846,967

6. CBA深圳新世纪88:96辽宁本钢
   🔥 10,819,474

7. 建议修改年休假天数规定
   🔥 9,434,709

8. 建议推行婴幼儿父母弹性上下班
   🔥 9,336,524

9. 从“投资于人”到“民生为大”
   🔥 9,220,301

10. 建议AI应用设计多考虑残疾人
   🔥 9,145,796


📱 数据来源：抖音网页端公开接口
⏰ 更新时间：2026/3/12 02:01:14

Security scan verdicts — ClawScan: suspicious | static analysis: suspicious | VirusTotal: clean | SkillSpector: suspicious (HIGH)