很久之前写的
[Python] 纯文本查看 复制代码 import requests
import re
yurl = input("请输入要下载的梨视频链接:")
file = input("请输入要将视频放在哪个目录:")
rem = re.compile('<title>(?P<titl>.*?)-Pear Video</title>')
id = yurl.split("_" , 1)[1]
head={
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36 Edg/100.0.1185.36",
"Referer": "https://www.pearvideo.com/video_" + id
}
url = f"https://www.pearvideo.com/videoStatus.jsp?contId={id}&mrd=0.9"
resp = requests.get(url=url,headers=head)
res = resp.json()
rep = str(res['videoInfo']['videos']['srcUrl'])
res = rep.split("-",2)[0].split("/",6)[6]
xid = "cont-"
repp = rep.replace(res ,xid + id)
print(repp)
rrp = requests.get(yurl,headers=head)
t = rem.finditer(rrp.text)
for tit in t:
titt = tit.group("titl")
rp = requests.get(url=repp,headers=head)
ofile = open(file + "\\" + titt + ".mp4", "wb+").write(rp.content)
|