当你需要获取今日头条实时热门新闻时使用此技能,适用于:
使用 toutiao-hot-news 技能获取最新热门新闻
或
帮我获取今日头条热榜前 10 条新闻
在终端执行:
python scripts/fetch_toutiao_hot_news.py
获取今日头条热榜,输出为 JSON 格式
或
获取今日头条热榜,用表格形式展示
【今日头条热榜 TOP10】更新时间:2026-04-03 09:50
1. [社会] 新闻标题内容... 🔥 热度:1234567
链接:https://www.toutiao.com/trending/xxxxx/
2. [国际] 新闻标题内容... 🔥 热度:987654
链接:https://www.toutiao.com/trending/xxxxx/
...
| 排名 | 分类 | 标题 | 热度值 | 链接 |
|---|---|---|---|---|
| ------ | ------ | ------ | -------- | ------ |
| 1 | 社会 | 新闻标题... | 1234567 | 查看 |
| 2 | 国际 | 新闻标题... | 987654 | 查看 |
{
"update_time": "2026-04-03 09:50:10",
"total_count": 10,
"news_list": [
{
"rank": 1,
"title": "新闻标题",
"category": "社会",
"hot_value": 1234567,
"url": "https://www.toutiao.com/trending/xxxxx/"
}
]
}
https://www.toutiao.com/hot-event/hot-board/?origin=toutiao_pcTitle: 新闻标题HotValue: 热度值Category: 新闻分类Label: 新闻标签Url: 新闻链接(需提取 ID 后拼接)pip install requests
或使用项目已有的虚拟环境:
.venv\Scripts\activate
pip install requests
Q: 为什么有时获取不到数据?
A: 检查网络连接,确保能访问 toutiao.com。如仍失败,可能是接口临时调整。
Q: 能否获取更多条新闻?
A: 可以。修改脚本中的 limit = 10 参数即可(最大支持 50 条)。
Q: 如何定时自动获取?
A: 可配合系统定时任务(Windows 任务计划程序 / Linux cron)定期执行脚本。
Q: 能否按分类筛选?
A: 当前版本获取全部分类热榜。如需筛选,可在获取后根据 category 字段过滤。
scripts/fetch_toutiao_hot_news.py - 主脚本文件scripts/__init__.py - Python 包初始化文件本技能仅供学习交流使用,请遵守相关法律法规和网站 robots.txt 协议。
共 2 个版本