Skip to content

Instantly share code, notes, and snippets.

@Devshimitsu
Last active April 6, 2021 15:27
Show Gist options
  • Save Devshimitsu/29d9dad1ba81e6e471fe50d10af00362 to your computer and use it in GitHub Desktop.
Save Devshimitsu/29d9dad1ba81e6e471fe50d10af00362 to your computer and use it in GitHub Desktop.
A file downloader with progress bar for terminal
from tqdm import tqdm
import requests
chunk_size = 1024
url = "https://i.ibb.co/qJk06vk/dev.png"
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!")
#BY_DEVSHIMITSU
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment