Get images from url.
#! /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))