Skip to content

Instantly share code, notes, and snippets.

@dpritchett
Created November 8, 2010 22:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dpritchett/668429 to your computer and use it in GitHub Desktop.
Save dpritchett/668429 to your computer and use it in GitHub Desktop.
Download a file using python
"""
See the python docs for more on file writes:
http://docs.python.org/tutorial/inputoutput.html#reading-and-writing-files
"""
import urllib
img = urllib.urlopen(r'http://www.google.com/logos/2010/xraydiscovery2010-res.gif')
f = open ('/pythonwrite.gif', 'wb') # wb = binary write mode
for line in img.readlines():
f.write(line)
f.close()
@dpritchett
Copy link
Author

Whipped up in answer to a question on StackOverflow chat.

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