无法使用progressbar33包

时间:2017-09-15 03:06:57

标签: python python-3.x

我想显示下载进度但我无法按预期工作 这是我的代码

import requests
from progressbar import Bar, ETA, FileTransferSpeed, ProgressBar


link = video_mp4_link
file_name = "download.mp4"

with open(file_name, "wb") as f:
    print("Downloading {}".format(file_name))
    response = requests.get(link, stream=True)
    total_length = int(response.headers.get('content-length'))

    widgets = ['[Downlaoding] ', Percentage(), ' ', Bar(),
            ' ', ETA(), ' ', FileTransferSpeed()]

    pbar = ProgressBar(widgets=widgets, maxval=total_length).start()
    for data in response.iter_content(chunk_size=4096):
        f.write(data)
        done = int(os.path.getsize('Tree_Scraper.py'))
        pbar.update(done)
    pbar.finish()


在下载文件时,它会显示如下进度:

[Downloading] 0% | | ETA: 35 days, 3:50:24 600 B/s 进度条停留在0%,ETA为35~100天,下载速度为 B / S !!


下载文件后,进度如下:

[Downlaoding] 100% |###############################| Time: 0:00:24 257.23 kB/s

使用的包装:

    progressbar33
    请求

那是怎么回事?

0 个答案:

没有答案