# 1.拿到contId # 2.拿到videoStatus返回的json. -> srcUrl # 3. srcUrl 里面的内容进行修整 # 4. 下载视频 import requests # 拉取视频的网址 -> 进入到指定某个视频页面源码 url = "https://www.pearvideo.com/video_1514115" contId = url.split("_")[1] videoStatusUrl = f"https://www.pearvideo.com/videoStatus.jsp?contId={contId}&mrd=0.543370355350492" headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36", # 防盗链:溯源,当前本次请求的上一级是谁 "Referer": url } resp = requests.get(videoStatusUrl,headers=headers) dic = resp.json() # print(dic) srcUrl = dic['videoInfo']['videos']['srcUrl'] systemTime = dic['systemTime'] srcUrl = srcUrl.replace(systemTime,f"cont-{contId}") # print(srcUrl) # https://video.pearvideo.com/mp4/adshort/20190202/cont-1514115-13551715_adpkg-ad_hd.mp4 # https://video.pearvideo.com/mp4/adshort/20190202/cont-1514115-13551715_adpkg-ad_hd.mp4 提取对比 # https://video.pearvideo.com/mp4/adshort/20190202/1643725981732-13551715_adpkg-ad_hd.mp4 # 下载视频 with open("PearFilm.mp4",mode="wb") as f: f.write(requests.get(srcUrl).content) print("提取视频完毕")运行结果
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)