Python 直接获取抖音直播的直播源
分析过程请参考 https://www.52pojie.cn/thread-1700738-1-1.html鉴于有些朋友不会抓包或者有问题 附上自己写的代码
可以直接获取flv和m3u8的直播源链接
import re
import sys
import requests
DEBUG = False
headers = {
'authority': 'v.douyin.com',
'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1',
}
url = input('请输入抖音直播链接或19位room_id:')
if re.match(r'\d{19}', url):
room_id = url
else:
try:
url = re.search(r'(https.*)', url).group(1)
response = requests.head(url, headers=headers)
url = response.headers['location']
room_id = re.search(r'\d{19}', url).group(0)
except Exception as e:
if DEBUG:
print(e)
print('获取room_id失败')
sys.exit(1)
print('room_id', room_id)
try:
headers.update({
'authority': 'webcast.amemv.com',
'cookie': '_tea_utm_cache_1128={%22utm_source%22:%22copy%22%2C%22utm_medium%22:%22android%22%2C%22utm_campaign%22:%22client_share%22}',
})
response = requests.get('https://webcast.amemv.com/webcast/room/reflow/info/?verifyFp=&type_id=0&live_id=1&room_id={}&sec_user_id=&app_id=1128&msToken=&X-Bogus='.format(room_id), headers=headers,).json()
print(response)
rtmp_pull_url = response['data']['room']['stream_url']['rtmp_pull_url']
hls_pull_url = response['data']['room']['stream_url']['hls_pull_url']
print(rtmp_pull_url)
print(hls_pull_url)
except Exception as e:
if DEBUG:
print(e)
print('获取real url失败') 请参考此贴的方法插入代码
【公告】发帖代码插入以及添加链接教程(有福利)
https://www.52pojie.cn/thread-713042-1-1.html
(出处: 吾爱破解论坛) 太棒了 竟然可以用 谢谢分享 jackymark 发表于 2022-10-19 04:55
太棒了 竟然可以用 谢谢分享
那必须的 苏紫方璇 发表于 2022-10-18 23:45
请参考此贴的方法插入代码
【公告】发帖代码插入以及添加链接教程(有福利)
https://www.52pojie.cn/thr ...
下次会注意的{:1_896:} 好像一个不错的功能!谢谢楼主分享 扛刀萝莉 发表于 2022-10-19 10:39
那必须的
{:1_921:}{:1_921:}{:1_921:}{:1_921:}{:1_921:} 感谢LZ
感谢LZ 现在不行了,大佬
页:
[1]