用requests下载视频

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/weixin_42370340/article/details/101430421

直接上代码

import requests

def down_video():
    header = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36'}
    url = 'http://shzjwxsns.video.qq.com/102/20202/snsvideodownload?filekey=30340201010420301e02016604025348041037274a53d2e6a1594adf2c3cfe68d35a020326daba040d00000004627466730000000131&hy=SH&storeid=32303139303132303033313131323030303864363461363964363439393935616536336530613030303030303636&dotrans=2&ef=15_0&bizid=1023'
    r = requests.get(url, headers=header, stream=True)
    with open('test.mp4', "wb") as mp4:
        for chunk in r.iter_content(chunk_size=1024 * 1024):
            if chunk:
                mp4.write(chunk)

down_video()

猜你喜欢

转载自blog.csdn.net/weixin_42370340/article/details/101430421