Created
February 6, 2018 23:50
-
-
Save skulltech/4510a5613c9aae89105fd1b6c424d0a0 to your computer and use it in GitHub Desktop.
Revisions
-
skulltech created this gist
Feb 6, 2018 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ import sys import requests def download(url, filename): with open(filename, 'wb') as f: response = requests.get(url, stream=True) total = response.headers.get('content-length') if total is None: f.write(response.content) else: downloaded = 0 total = int(total) for data in response.iter_content(chunk_size=max(int(total / 1000), 1024 * 1024)): downloaded += len(data) f.write(data) done = int(50 * downloaded / total) sys.stdout.write('\r[{}{}]'.format('█' * done, '.' * (50 - done))) sys.stdout.flush() sys.stdout.write('\n')