'Downloading image with requests results in unrecognized file format

I'm trying to download a couple of images in my script, but even though the images seem to download, they seem to be corrupted or unrecognized. And I'm not sure what I'm doing wrong. This is the part of my code:

tshirt_pic = requests.get("https://www.innovasport.com/medias/playera-nike-jordan-jumpman-is-CJ0921-011-1.png?context=bWFzdGVyfGltYWdlc3w1MDg4MnxpbWFnZS9wbmd8aW1hZ2VzL2g3ZS9oMjgvOTc1OTk4MjY4MjE0Mi5wbmd8NTZlODA5YzhmMDZmOGMyYTBkODliMGM3NGE0NGE0YzBlOThhMTAzM2ZmMWMyODM4M2ZjNTVjNmNmZWExM2VkNw").content
with open('my_pic.png', 'wb') as file:
    file.write(tshirt_pic)

If I copy the image link in my browser, it opens correctly. But when using my script, the png donwloaded just can't be opened... Do you guys know what am I doing wrong?



Solution 1:[1]

You're getting <Response [403]>

Doing something like this is probably the easiest:

curl

Then translate it with something like: https://reqbin.com/req/python/c-xgafmluu/convert-curl-to-python-requests

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1