How to download and save all images from a URL?

How to download and save all images from a URL?

QA 0

To download all images from a given website, we can iterate through all ‘img’ elements, and leverage the ‘urlretrieve’ method to save them to our computer. Sample code below:

Python Code:

import win32com.client
x = win32com.client.Dispatch("AppRobotic.API")
from selenium import webdriver
import urllib.request

# navigate to Instagram
driver = webdriver.Firefox()
driver.get('https://www.instagram.com')
# sleep 1 second
x.Wait(1000)

images = self.driver.find_elements_by_tag_name('img')
for img in images:
source = img.get_attribute("src")
# sleep 1 second
x.Wait(1000)
urllib.urlretrieve(source)