Skip to content

Instantly share code, notes, and snippets.

@yurivictor
Created April 6, 2012 01:40
Show Gist options
  • Select an option

  • Save yurivictor/2315856 to your computer and use it in GitHub Desktop.

Select an option

Save yurivictor/2315856 to your computer and use it in GitHub Desktop.
Downloads and saves images from web sites
import requests
images = ['http://url.to/image.jpg', 'http://url.to/image.jpg']
def get_photos():
# Iterates through the list of images
for image in images:
# Gets the image from the url
request = requests.get(image)
# Opens a file locally
file = open(image, 'w')
# Writes the image to the file
file.write(request.content)
# Closes the file
file.close()
print 'Saving ' + image
get_photos()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment