I am trying to download an image using PIL but its shows an UnidentifiedImageError
d = login_session.get("https://example.com/xyz.php")
d = Image.open(BytesIO(d.content))
d.save("xyz.png")
Here I need to log into a site first and then download an image, so for that, I used login_session to make a session
File "C:/Users/dx4io/OneDrive/Desktop/test.py", line 21, in <module>
captcha = Image.open(BytesIO(captcha.content))
File "C:\Users\dx4io\AppData\Local\Programs\Python\Python37\lib\site-packages\PIL\Image.py", line 3024, in open
"cannot identify image file %r" % (filename if filename else fp)
PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x000001A5E1B5AEB8>