Skip to content

Instantly share code, notes, and snippets.

@siennathesane
Created September 8, 2015 04:28
Show Gist options
  • Select an option

  • Save siennathesane/44ff9fd35065a5a211f4 to your computer and use it in GitHub Desktop.

Select an option

Save siennathesane/44ff9fd35065a5a211f4 to your computer and use it in GitHub Desktop.
import requests
#http://docs.python-requests.org/en/latest/
def downloader(url,file):
with open(file,'wb') as f:
request = requests.get(url, stream=True)
for chunk in request.iter_content(chunk_size=1024):
if chunk:
f.write(chunk)
f.flush()
#http://stackoverflow.com/questions/16694907/how-to-download-large-file-in-python-with-requests-py
downloader('http://vapp-updates.vmware.com/vai-catalog/valm/vmw/302ce45f-64cc-4b34-b470-e9408dbbc60d/5.8.4.207.latest/package_pool/kernel-default-3.0.101-0.46.1.x86_64.rpm','kernel-default-3.0.101-0.46.1.x86_64.rpm')
# you forgot to stream the download. otherwise it will only download the first 1k chunk and be done.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment