本帖最后由 wushaominkk 于 2019-6-6 20:58 编辑
源码+成品下载地址:https://www.lanzouj.com/i37nt2j
代码:
[Python] 纯文本查看 复制代码 import requests
import re
import tkinter as tk
#用户名:<p class="name nowrap">(.*?)</p>
#简介:<p class="desc">(.*?)</p>
#封面:cover: "(.*?)"
#播放地址:playAddr: "(.*?)"
#[url=https://aweme.snssdk.com/aweme/v1/playwm/]https://aweme.snssdk.com/aweme/v1/playwm/[/url]去掉wm无水印
headers = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.96 Safari/537.36'}
def make_it():
Text1.delete('1.0','end') #清空Text
url = Entry1.get()
try:
#获取302重定向地址
html1 = requests.head(url)
true_url = html1.headers['Location']
html2 = requests.get(true_url,headers = headers)
#print(html2.text)
text_data = html2.text
#视频名字
video_name = re.findall('<p class="name nowrap">(.*?)</p>',text_data,re.S)[0]
#视频简介
video_summary = re.findall('<p class="desc">(.*?)</p>',text_data,re.S)[0]
#视频封面
#video_cover = re.findall('cover: "(.*?)"',text_data,re.S)[0]
#视频水印播放地址
video_player_url1 = re.findall('playAddr: "(.*?)"',text_data,re.S)[0]
#视频去水印播放地址
video_player_url2 = video_player_url1.replace('wm','')
Label1_summary["text"] = video_name + ' ' + video_summary
Text1.insert('insert',video_player_url2)
#print(video_player_url2)
except:
Label1_summary["text"] = "Error"#设置标签内容
Text1.insert('insert','Error') #Text插入文本
#以下是主函数
windows = tk.Tk()
windows.geometry('533x270')
windows.resizable(0,0)
windows.title('抖音视频无水印解析 BY:Snow')
Entry1=tk.Entry(windows)
Entry1.place(height = 36,width = 372,x = 14,y = 24)
Button1=tk.Button(windows,text = '解析',command = make_it)
Button1.place(height = 36,width = 126,x = 396,y = 24)
Label1_summary=tk.Label(windows,text = 'video简介',justify = 'left',wraplength = 508,anchor = 'n')
Label1_summary.place(height = 71,width = 508,x = 15,y = 70)
Text1=tk.Text(windows)
Text1.place(height = 108,width = 508,x = 15,y = 149)
windows.mainloop()
python+tkinter写的,pyinstaller编译,exe文件比较大,没法查毒,介意的下载源码使用。
代码里有一个视频封面的参数我给注释掉了,要是在GUI界面中显示在线图片,需要借助其他库,太麻烦就不要了。
就直接解析出视频地址了。
悄悄告诉你,这个tkinter gui界面是我用https://www.52pojie.cn/thread-873730-1-1.html布局的,布局快速多了。
|