
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
How to download Google Images using Python
Google offers many python packages which minimize the effort to write python code to get data from google services. One such package is google images download. It takes in the key words as parameters and locates the images with those keywords.
Example
In the below example we limit the number of images to 5 and also allow the program to print the urls from where the files were generated.
from google_images_download import google_images_download #instantiate the class response = google_images_download.googleimagesdownload() arguments = {"keywords":"lilly,hills","limit":5,"print_urls":True} paths = response.download(arguments) #print complete paths to the downloaded images print(paths)
Output
Running the above code gives us the following result −
Image URL: https://assets.traveltriangle.com/blog/wp-content/uploads/2017/11/Hill-Stations-Near-Kolkata-cover1-400x267.jpg Completed Image ====> 4.Hill-Stations-Near-Kolkata-cover1-400x267.jpg Image URL: https://image.shutterstock.com/image-photo/distant-hills-hilly-steppe-curvy-260nw-1037414248.jpg Completed Image ====> 5.distant-hills-hilly-steppe-curvy-260nw-1037414248.jpg ({'lilly': ['C:\python3\downloads\lilly\1.Lilly-Tougas.jpg', 'C:\python3\downloads\lilly\2.1200px-Eli_Lilly_and_Company.svg.png', ' C:\python3\downloads\lilly\3.nikki-lilly-this-morning.jpg', 'C:\python3\downloads\lilly\4.lily-plants.jpg', 'C:\python3\downloads\lilly\5.dish-lilly-ghalichi.jpg'], 'hills': ['C:\python3\downloads\hills\1.220px-Clouds_over_hills.jpg', 'C:\python3\downloads\hills\2.Bacin_zari_2015.jpg', 'C:\python3\downloads\hills\3.65ad9ac0-0455-4086-a4f4-1245f697d10e.png', 'C:\python3\downloads\hills\4.Hill-Stations-Near-Kolkata-cover1-400x267.jpg', 'C:\python3\downloads\hills\5.distant-hills-hilly-steppe-curvy-260nw-1037414248.jpg']}, 1)
- Related Articles
- How to download images using Invoke-Webrequest in PowerShell?
- How to use Android Picasso library to download images using Kotlin?
- How to use Android Picasso Library to download images?
- How to Disable images in Selenium Google ChromeDriver?
- How to download APK files from Google Play Store on Linux
- How to download all images on a web page at once?
- Disable images in Selenium Google ChromeDriver.
- Reading images using Python?
- How to automate google Signup form in Selenium using Python?
- How to compare histograms of two images using OpenCV Python?
- How to blend images using image pyramids in OpenCV Python?
- How to download a file using Node.js?
- YouTube Media/Audio Download using Python - pafy
- How to join two images horizontally and vertically using OpenCV Python?
- How to apply custom filters to images (2D convolution) using OpenCV Python?

Advertisements