赞
踩
用requests库直接获取抖音分享后的短连接的response。不需要自己去解析。
自动回解析出长链接。
里面包含了直播流等信息,然后可以通过json获取出来,我比较懒,直接用正则提取一下就行了!
然后通过 PotPlayer 软件就可以录制了。或者直接obs进行无人转播等。就这么简单。。。。
举例说明一下:
首先运行脚本,当然你需要有requests第三方库,当然玩爬虫的这个也是必备的。手机里面分享短连接出来后,直接运行脚本,复制短连接后。
回车运行后,直接在后面正则匹配到直播源。
然后就通过这个 potplayer 这个播放器 进行录制或者转播就行了!
附带小脚本大家可以借鉴一下啊!
# -*- coding: utf-8 -*- # @Time : 2020/12/4 22:04 # @Author : Steven # @QQ : 2621228281 # @Email : 2621228281@qq.com # @File : douyinJiexi.py # @Software: PyCharm import re import requests import urllib3 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) def run(): print('\n') print('=========================================================================') print(' 【抖音直播源解析小工具】By:Steven QQ:2621228281') print('=========================================================================') print('请注意只复制网址,不复制文字进入,如:https://v.douyin.com/JXkLCLX/') print('\n') print('=========================================================================') print('输入后按回车键获取直播源') print('=========================================================================') url = str(input('请输入抖音短网址:')) print('=========================================================================') headers = { 'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', 'accept-encoding': 'gzip, deflate, br', 'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,ja;q=0.7', 'sec-ch-ua': '"Google Chrome";v="89", "Chromium";v="89", ";Not A Brand";v="99"', 'sec-ch-ua-mobile': '?0', 'sec-fetch-dest': 'document', 'sec-fetch-mode': 'navigate', 'sec-fetch-site': 'none', 'sec-fetch-user': '?1', 'upgrade-insecure-requests': '1', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.72 Safari/537.36', } response = requests.get(url,headers=headers,verify=False) # print(response.text) live_stream = re.findall(r'hls_pull_url":"(.*?)",',response.text)[0] with open('解析直播源.txt','a',encoding='utf-8')as f: f.write(live_stream+'\n') f.close() print(live_stream) print('=========================================================================') if __name__ == '__main__': while True: run() choice = input('是否继续解析其他直播间地址(yes/no):') print('=========================================================================') if choice == 'no': quit
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。