Skip to content

Instantly share code, notes, and snippets.

@mjcarroll
Created January 16, 2013 17:45
Show Gist options
  • Select an option

  • Save mjcarroll/4549128 to your computer and use it in GitHub Desktop.

Select an option

Save mjcarroll/4549128 to your computer and use it in GitHub Desktop.
import urllib2, shutil, tempfile
import tarfile
import os
try:
from urllib.request import urlretrieve
except ImportError:
import urllib2, shutil, tempfile, os
def urlretrieve(url):
fd, fname = tempfile.mkstemp() # Make a temporary file
f = os.fdopen(fd, "w")
resp = urllib2.urlopen(url)
shutil.copyfileobj(resp.fp, f) # Copy the http response to the temporary file.
return (fname, None)
if __name__=='__main__':
(filename, headers) = urlretrieve('https://github.com/vcstools/vcstools/archive/0.1.26.tar.gz')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment