DEV Community

Cover image for How to save Google search images with a single command
Ichi
Ichi

Posted on

How to save Google search images with a single command

Around August 2020, the method of providing results in Google search seems to have changed significantly, and the Windows software "ImageSpider" can no longer be used. (It was quite convenient, though ...)
So from now on, I decided to use the Python library "google_images_download".

Installation

[Caution] Do not install with pip!
The version in PIP does not support changes on the Google side, so it cannot be used even if it is installed.
So install it directly.

git clone https://github.com/Joeclinton1/google-images-download.git
cd google-images-download && sudo python setup.py install
Enter fullscreen mode Exit fullscreen mode

This completes the installation.

How to use

Here, as a typical usage, the usage method on the command line is listed.

googleimagesdownload --keywords "apple" --limit 20
Enter fullscreen mode Exit fullscreen mode

In the above example, 20 search results for "apple" will be saved in the current directory.

Please see official document for how to use it on Python and other condition settings.

When acquiring 100 or more

If you want to get more than 100 images, you need to install chrome driver.

  • This is the operation method for Ubuntu 20.04 LTS. For Windows, please check by yourself m (_ _) m

First check the latest version of the driver
Please go to the following site and copy the latest version of "chromedriver_linux64.zip" URl.

Then enter the following command in succession. (I referred to this article.)

sudo apt install unzip
cd /tmp/
curl -O <<<<<Enter the URL you just confirmed here>>>>>
unzip chromedriver_linux64.zip
mv chromedriver /usr/local/bin/
rm chromedriver_linux64.zip
Enter fullscreen mode Exit fullscreen mode

This completes the installation.

Command to get 100 or more

googleimagesdownload --keywords "apple" --limit 120 --chromedriver /usr/local/bin/chromedriver
Enter fullscreen mode Exit fullscreen mode

Just select the installation destination with the --chromedriver option for the one I introduced earlier.

↓ Acquisition result
Alt Text

You have obtained it properly.
Alt Text

I've written a lot, so please take a look at my blog.

Top comments (1)

Collapse
 
joel_b98041d14a2d profile image
Joel

Hi,
I am new to setting up stuff on linux to work with python, please excuse my newbie-ness. While trying to install via setup.py I constantly get the following error: error: cryptography 2.8 is installed but cryptography>=35.0 is required by {'pyOpenSSL'}
Would you know what I am doing wrong? Thanks for any help.