import requests def get_image_from_url(url): f = open('pic.jpg','wb') f.write(requests.get(url).content) f.close() f = open('pic.jpg','rb') file = f.read() f.close() return file