import requests def download_file(url, path): with requests.get(url, stream=True) as r: chunk_size = 1024 content_size = int(r.headers['content-length']) print(r,'ks') '下载开始' with open(path, "wb") as f: for chunk in r.iter_content(chunk_size=chunk_size): f.write(chunk) if __name__ == '__main__': url='https://vd3.bdstatic.com//mda-meuj6t9f3z2j7bse//cae_h264_clips//1622296906542144945//mda-meuj6t9f3z2j7bse.mp4?auth_key=1622692948-0-0-3f8373256cde17047e56ac87175eb1bc&bcevod_channel=searchbox_feed&pd=1&pt=3&abtest=' path = './a.mp4' download_file(url, path)