用requests下载视频

直接上代码

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()

你可能感兴趣的:(网络爬虫)