头条资讯文章里面的视频的链接提取,学习使用
·
直接就开始
打开 开发者模式,搜索: tt-videoid。
看到这里有个 data-token, 这是个 bs64 加密的东西,直接使用 解密
import base64
import json
encoded_str = " 替换成 你看到的东西"
# 1. Base64 解码
decoded_bytes = base64.b64decode(encoded_str)
decoded_json = json.loads(decoded_bytes)
# 2. 格式化输出
# print(json.dumps(decoded_json, indent=2, ensure_ascii=False))
# 3. 提取并解析内部的 GetPlayInfoToken (Unicode转义字符串)
token_raw = decoded_json.get("GetPlayInfoToken", "")
# 将 \u0026 等 unicode 转义还原为真实字符
token_parsed = token_raw.encode().decode('unicode_escape')
print("\n--- GetPlayInfoToken 解析结果 ---")
print(token_parsed)
video_url = 'https://vod.bytedanceapi.com/?' + token_parsed
print(video_url )
这样子就可以拿到
这样子的数据, 解析下,里面的 Definition 是分辨率, MainPlayUrl 视频地址。
更多推荐
所有评论(0)