
抖音用户视频列表接口分析
1、从抖音 APP 分享个人信息,复制链接,获得个人主页地址,示例:
2、使用 Chrome 抓包,获取视频列表接口的请求信息


参数分析:
- user_id: 用户ID,可从 HTML 中提取
- count: 视频数量
- max_cursor: 视频索引位置,用于翻页
- aid: 固定值
- _signature: 实时签名值,由签名算法计算
- dytk: 用户 token,可从 HTML 中提取
3、定位 _signature 签名算法




4、分析签名算法的执行逻辑
- ① 定义
__M
对象,及其define
和require
函数 - ② 执行
__M.define("douyin_falcon:node_modules/byted-acrawler/dist/runtime......"
这段代码 - ③ 执行
_bytedAcrawler = require("douyin_falcon:node_modules/byted-acrawler/dist/runtime")
- ④ 计算签名值
_signature = _bytedAcrawler.sign(user_id)
使用 NodeJS 提供签名计算服务
此处可能存在跨语言频繁调用的场景,所以使用 grpc 提供服务。
中途遇到的问题
1、userAgent 属性不存在
Debug 分析抖音 API 请求流程,userAgent 属性在 navigator 对象中,所以需要定义全局对象:
global.navigator = {
userAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1"
};
2、document 对象不存在
- 解决方式一:删除 document 相关代码
- 解决方式二:https://stackoverflow.com/questions/32126003/node-js-document-is-not-defined
最终效果演示



小姐姐定制版抖音页面: https://anoyi.com/dy/96956380265
提示:页面若未出现视频列表,向下滑动整体页面,自动加载,前端太菜,将就体验。。。。
网友评论