Python: How to Save Image from URL

If you have a web URL for an Image and you want to save it to a specific location using Python then you can make use of the requests module.

The first thing is you should make sure that you have installed the requests module using pip.

pip install requests
pip3 install requests

Example:

import requests

image_url = "https://code2care.org/c2c-img/icons/python.png"

image_content = requests.get(image_url).content

with open('python.png', 'wb') as handler:
    handler.write(image_content)
How to Save an Image from URL in Python Example

Comments & Discussion

Facing issues? Have questions? Post them here! We're happy to help!