import requests
url = input("输入梨视频网址:")
#url = "https://www.pearvideo.com/video_1743115"
countId = url.split("_")[1]
headers = {
"Referer": url,
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36 Edg/94.0.992.38"
}
requesturl = f"https://www.pearvideo.com/videoStatus.jsp?contId={countId}&mrd=0.4108455213337001"
resp = requests.get(requesturl, headers=headers)
dic = resp.json()
scrurl = dic['videoInfo']['videos']['srcUrl']
systime = dic['systemTime']
newurl = scrurl.replace(systime, f"cont-{countId}")
with open("a.mp4", mode="wb") as f:
f.write(requests.get(newurl).content)
print("over")
自己边看边学的