Skip to content

Instantly share code, notes, and snippets.

@bazuzu931
Last active February 10, 2017 14:33
Show Gist options
  • Save bazuzu931/6a91f0d2065c421d2b6286fcf5d44ffd to your computer and use it in GitHub Desktop.
Save bazuzu931/6a91f0d2065c421d2b6286fcf5d44ffd to your computer and use it in GitHub Desktop.
download_big_file_by_chunks.py
import requests
def download(url):
file = url.split('/')[-1]
if file.split('.')[-1] != "mp3":
file += ".mp3"
r = requests.get(url, stream=True)
with open(file, 'wb') as f:
for chunk in r.iter_content(chunk_size=1024):
if chunk:
f.write(chunk)
return file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment