防盗链的处理:没完成

Posted J哥。

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了防盗链的处理:没完成相关的知识,希望对你有一定的参考价值。

防盗链的处理:没完成

# 1.拿到cont  id
# 2.拿到videoStatus 返回的json.--> srcURL
# 3. srcURL 里面的内容进行修整
# 4.进行下载视频


# 防盗链 :Referer: https://www.pearvideo.com/video_1670880
# 防盗链 : 溯源 ,当前本次请求的上一级是谁


import requests
import json


url = 'https://www.pearvideo.com/video_1728717'
countID = url.strip("_")[-1]

videoStatusurl = f"https://www.pearvideo.com/videoStatus.jsp?contId={countID}&mrd=0.9985367825928784"

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (Khtml, like Gecko) Chrome/90.0.4430.93 Safari/537.36',
    'Referer': url,
    'Cookie': '__secdyid=27de06ad0a8da9a14f3b540e41c7cb467509bf8414ad2e94021620393157; JSESSIONID=871D99A140EF47CFDA8A301EFB7FA1D1; PEAR_UUID=124a7179-60ae-4f9b-b9c5-b795a6ada8bf; _uab_collina=162039315798804155909594; Hm_lvt_9707bc8d5f6bba210e7218b8496f076a=1620393158; UM_distinctid=17946f566d5a-0047bbc1afb132-d7e1739-1fa400-17946f566d671; p_h5_u=DD60EA33-AA2F-4802-B2B5-22E0F0483FBC; CNZZDATA1260553744=805876215-1620391095-https%253A%252F%252Fwww.baidu.com%252F%7C1620395494; acw_tc=781bad3616203997211672753e0c82bd49d4cbac44c3f57bc3b78bffa91b7a; Hm_lpvt_9707bc8d5f6bba210e7218b8496f076a=1620399723; SERVERID=bacac21aafa9027952fdc46518c0c74f|1620399782|1620393157'
}

resp = requests.get(headers=headers,url=videoStatusurl)
# resp.encoding = 'utf-8'
dic =resp.json()
# Set-Cookie: SERVERID=bacac21aafa9027952fdc46518c0c74f|1620399782|1620393157;Path=/
#
# srcurl = dic['videoInfo']['videos']['srcUrl']
systemTime = dic['systemTime']
# srcurl =srcurl.replace(systemTime,f"cont-{countID}")
# print(srcurl)
# <img class="img" src="https://image.pearvideo.com/cont/20200424/cont-1670880-12367380.png" alt="独腿画家流浪36年:生活磨难让我学会感恩,劳动维生不卑微">
# <video webkit-playsinline="" playsinline="" x-webkit-airplay="" style="width: 100%; height: 100%;" src="https://video.pearvideo.com/mp4/adshort/20210506/cont-1670880-4635-160356_adpkg-ad_hd.mp4"></video>
# 保存视频
#
# with open("a.mp4",mode= "wb" ) as  f:
#     f.write(requests.get(srcurl).content)

# print(resp.json())
print(dic)

 

以上是关于防盗链的处理:没完成的主要内容,如果未能解决你的问题,请参考以下文章

apache 防盗链和隐藏版本

iOS 图片和音频的防盗链的应用

HTTP协议之防盗链与反防盗链

Nginx环境下对部分网站做防盗链设置及外链的跳转

nginx防盗链和代理配置

网站防盗链的配置之apache