I see that there are two ways to download images using python-reuqests.
Uisng PIL as stated in docs (https://requests.readthedocs.io/en/master/user/quickstart/#binary-response-content):
from PIL import Image from io import BytesIO i = Image.open(BytesIO(r.content))
using streamed response content:
r = requests.get(url, stream=True) with open(image_name, 'wb') as f: for chunk in r.iter_content(): f.write(chunk)
Which is the recommended wya to download images however? both have its merits I suyppose, and I was wondering what is the optimal approach.