import time import requests class DownLoad: @classmethod def download_video(cls, video_url, video_path_url): try: for i in range(3): payload = {} headers = {} response = requests.request("GET", video_url, headers=headers, data=payload, timeout=50) if response.status_code == 200: # 以二进制写入模式打开文件 video = video_path_url + 'video.mp4' with open(f"{video}", "wb") as file: # 将响应内容写入文件 file.write(response.content) time.sleep(5) return video return None except Exception: return None