抖音作者已关闭下载的视频怎么下载(抖音作者已关闭下载的视频怎么下载不了)
更新时间:2023-05-09 16:43:44来源:金符游戏浏览量:
直接复制以下代码即可import requestsimport osimport reimport time headers = { "User-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36"}api = "https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids=" # 创建目录def createFolder(dirname): if os.path.exists(dirname): pass else: os.mkdir(dirname) #def get_url(content): url = re.search(r"[a-zA-z]+://[^\s]*", content).group(0) requestsApi(url) # 获取真实地址 匹配aweme_iddef handleUrl(url): response = requests.get(url).url aweme_id = re.match(r".*video/(\d+)", response).group(1) return aweme_id # 解析视频def requestsApi(url): result = requests.get(api + handleUrl(url), headers=headers).json() vid = result["item_list"][0]["video"]["play_addr"]["uri"] video_name = result["item_list"][0]["desc"] video_api = "https://aweme.snssdk.com/aweme/v1/play/?video_id=" + vid + "∶=720p&line;=0" start = time.time() video = requests.get(video_api, headers=headers. stream=True) size = 0 # 初始化已下载大小 chunk_size = 1024 # 每次下载的数据大小 content_size = int(video.headers['content-length']) try: if video.status_code == 200: print('开始下载,[视频大小]:{size:.2f} MB'.format(size=content_size / chunk_size / 1024)) # 开始下载,显示下载文件大小 filename = os.path.join(folder_name, f"{video_name}" + ".mp4") with open(filename, "wb") as f: for data in video.iter_content(chunk_size=chunk_size): f.write(data) size += len(data) print('\r' + '[下载进度] %s %.2f%%' % ( '▊' * int(size * 50 / content_size), float(size / content_size * 100)), end=' ') end = time.time() print('视频下载完成!, 完成时间: %.2f秒' % (end - start)) # 输出下载用时时间 except Exception as ex: print("err: ", ex) if __name__ == '__main__': folder_name = "video" createFolder(folder_name) get_url(input( "请输入抖音的分享链接!比如 (5.30 AtR:/ %%月光骑士 帅是很帅,就是有点废厕纸。 https://v.douyin.com/YxEqmuF/ 复制此链接,打开Dou音搜索,直接观看视频!)\n")) t = 5 n = 0 while n < t: n = n + 1 time.sleep(1) print(f"{n}秒后关闭窗口!") if n == t: break
以上就是抖音作者已关闭下载的视频怎么下载的详细内容,更多抖音作者已关闭下载的视频怎么下载不了内容请关注金符游戏其它相关文章!