response = requests.get("https://i.imgur.com/ExdKOOz.png") file = open("sample_image.png", "wb") file.write(response.content) file.close()
Here is what the above code is Doing:
1. We’re using the requests library to make a GET request to the URL of the image.
2. We’re then saving the response to a variable called response.
3. We’re opening a file called sample_image.png and writing the contents of the response to it.
4. We’re then closing the file.