Created
April 6, 2012 01:40
-
-
Save yurivictor/2315856 to your computer and use it in GitHub Desktop.
Downloads and saves images from web sites
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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