-
-
Save AnoRebel/56def282f1fe40f2d503a069d612af39 to your computer and use it in GitHub Desktop.
A file downloader with progress bar for terminal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tqdm import tqdm | |
import requests | |
chunk_size = 1024 | |
url = "http://www.nervenet.org/pdf/python3handson.pdf" | |
r = requests.get(url, stream = True) | |
total_size = int(r.headers['content-length']) | |
filename = url.split('/')[-1] | |
with open(filename, 'wb') as f: | |
for data in tqdm(iterable = r.iter_content(chunk_size = chunk_size), total = total_size/chunk_size, unit = 'KB'): | |
f.write(data) | |
print("Download complete!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment