How to Download Image from URL using Python?

By Hardik Savani October 30, 2023 Category : Python

Hey Folks,

In this tutorial, we will go over the demonstration of python download image from url and save. This post will give you a simple example of how to download image from url using python. you can see python download image from url.

There are several ways to download image from url in python. we will use urllib and requests library to download image from link. urllib library urlretrieve method will use and requests library get method will use. so let's see the both example code:

Example 1:

import urllib.request
urllib.request.urlretrieve("", "demo.png")

Example 2:

import os
import requests
imageURL = ''
page = requests.get(imageURL)
f_ext = os.path.splitext(imageURL)[-1]
f_name = 'img{}'.format(f_ext)
with open(f_name, 'wb') as f:

I hope it can help you...

Tags :