[英]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.