Skip to content

Instantly share code, notes, and snippets.

@leftrk
Created December 11, 2019 18:37
Show Gist options
  • Save leftrk/b9e714e6fbd71c843839a9725cdd9dfd to your computer and use it in GitHub Desktop.
Save leftrk/b9e714e6fbd71c843839a9725cdd9dfd to your computer and use it in GitHub Desktop.
download file
def downloadFILE(url, name):
resp = requests.get(url=url, stream=True)
content_size = int(resp.headers['Content-Length']) / 1024
with open(name, "wb") as f:
print("File total size is:", content_size, 'k,start...')
for data in tqdm(iterable=resp.iter_content(1024), total=content_size + 1, unit='k', desc=name):
f.write(data)
print(name + " download finished!")
@tgalliganwork
Copy link

Code didn't run for me. Received a module not callable error. You need to call the function inside tqdm so tqdm.tqdm()

@leftrk
Copy link
Author

leftrk commented Feb 6, 2021

Code didn't run for me. Received a module not callable error. You need to call the function inside tqdm so tqdm.tqdm()

you must install tqdm with pip;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment