Created
November 13, 2014 23:46
-
-
Save wkentaro/4a2d4c2378d1834d8f6a to your computer and use it in GitHub Desktop.
Get images from url.
This file contains 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
#! /usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# main.py | |
import sys | |
from PIL import Image | |
import requests | |
from io import BytesIO | |
f = open('image_urls.txt', 'rb') | |
rows = f.readlines() | |
for i, url in enumerate(rows): | |
try: | |
response = requests.get(url) | |
img = Image.open(BytesIO(response.content)) | |
except IOError: | |
continue | |
img.save('imgs/train{}.png'.format(i)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment