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