import requests, os
from tqdm import tqdm
eg_link = "https://caspersci.uk.to/matryoshka.zip"
response = requests.get(eg_link, stream=True)
with tqdm.wrapattr(open(os.devnull, "wb"), "write",
miniters=1, desc=eg_link.split('/')[-1],
total=int(response.headers.get('content-length', 0))) as fout:
for chunk in response.iter_content(chunk_size=4096):
fout.write(chunk)
From here https://github.com/tqdm/tqdm#hooks-and-callbacks Originally here https://stackoverflow.com/a/53877507/252556