
We can now clean all of the image URLs inside of every dictionary key and change all of the relative URL paths to exact URL paths.

# We can split the file based upon / and extract the last split within the python list below: We’ll also create a python list to store any broken image URLs that didn’t return a 200 status code: broken_images = image_urls = for img in image_urls: In order to download the multiple images, we’ll use the requests library. Method One: How To Download Multiple Images From A Python List Users/jamesaphoenix/Desktop/Imran_And_James/Python_For_SEO/6_downloading_multiple_images/all_images # os.chdir('path') os.chdir('all_images') !pwd Requirement already satisfied: six in /opt/anaconda3/lib/python3.7/site-packages (from requests-file>=1.4->tldextract) (1.14.0) import requestsĬhanging into the directory of the folder called all_images, this can be done by either: # !cd all_images Requirement already satisfied: chardet=3.0.2 in /opt/anaconda3/lib/python3.7/site-packages (from requests>=2.1.0->tldextract) (3.0.4) Requirement already satisfied: idna in /opt/anaconda3/lib/python3.7/site-packages (from tldextract) (2.8) Requirement already satisfied: requests-file>=1.4 in /opt/anaconda3/lib/python3.7/site-packages (from tldextract) (1.5.1) Requirement already satisfied: setuptools in /opt/anaconda3/lib/python3.7/site-packages (from tldextract) (46.0.0.post20200309) Requirement already satisfied: requests>=2.1.0 in /opt/anaconda3/lib/python3.7/site-packages (from tldextract) (2.22.0) Python Imports !pip install tldextract Requirement already satisfied: tldextract in /opt/anaconda3/lib/python3.7/site-packages (2.2.2) We will also include error handling so that if a URL no longer exists the code will still work.Make a request to download all of the images, one by one.

