python下载mp4

02/02 12:26
阅读数 99

 

 

 

urllib.request.urlretrieve(video_url,'./videos/%s.mp4'%(title))

 

下载多了不能用了;

  req = requests.get(url, headers=self.headers, stream=True, verify=False,timeout=500)
            with(open(target_dir + movie_name + '.mp4', 'wb')) as f:

                pbar = tqdm(total=100)
                for chunk in req.iter_content(chunk_size=10000):
                    if chunk:
                        f.write(chunk)
                        downsize += len(chunk)
                        # line = 'downloading %d KB/s - %.2f MB, 共 %.2f MB'
                        pbar.update(1)
                        # line = line % (
                        #     downsize / 1024 * 5 / (time.time() - startTime), downsize / 1024 * 5 / 1024 * 5,
                        #     downsize / 1024 * 5 / 1024 * 5)
                        # print(line)
                pbar.close()

 

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部