繁体   English   中英

Python wget 模块不显示进度条

[英]Python wget module doesn't show progress bar

我正在尝试使用 wget 模块下载 python 中的文件。 我知道它应该有几种进度条模式,但实际上并未在控制台中显示。

我找不到此模块的任何文档。

import wget
from pathlib import Path

print('Beginning download...')

url = 'https://storage.googleapis.com/meirtvmp3/archive/hebrew/mp3/sherki/daattvunot/idx_69115.mp3'
wget.download(url)

文件下载但没有进度条显示。

该模块的源代码确实有对其的引用。 但是当我在我的代码 python 中尝试它时,找不到对它的引用。

编辑

我从终端测试了脚本,它按预期工作。 我想这是一个 pycharm/venv 错误。

这对我有用,

#create this bar_progress method which is invoked automatically from wget
def bar_progress(current, total, width=80):
  progress_message = "Downloading: %d%% [%d / %d] bytes" % (current / total * 100, current, total)
  # Don't use print() as it will print in new line every time.
  sys.stdout.write("\r" + progress_message)
  sys.stdout.flush()

#Now use this like below,
url = 'http://url_to_download'
save_path = "/home/save.file"
wget.download(url, save_path, bar=bar_progress)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM