A python codebase that downloads images from Google Browser with the search term mentioned.
The above code base is written in python and downloads images from Google with the search term of your choice.
-
Install Google Chrome (skip if its already installed).
-
Identify your Chrome version by typing below command.
$ google-chrome --version
and displays like this
Google Chrome 81.0.4044.122
- Download corresponding ChromeDriver from below link.
-
Unzip the chromedriver.zip
-
Move the file to /usr/bin directory
$ sudo mv chromedriver /usr/bin
then move to below folder
$ cd /usr/bin
- Now, you would need to run something like
$ sudo chmod a+x chromedrive
and mark it executable.
- Clone the code and open the terminal and type the following command
$ bash requirements.sh
the above file will download all the required images
After downloading the required packages The code has two parts
- Searching for a specific term & get image links
- Downloading the images
The function find_and_download expects four input parameters:
search_term : Search term, like Cat
driver_path : instantiated Webdriver
target_path : images folder
number_images : No of images to download
Eg: find_and_download(search_term ="Cat", \
driver_path = "/usr/bin/chromedriver", \
target_path='./images', \
number_images=100)
Make the above changes in code and save it
- Finally run the below command to run the script
$ python3 scrap_image.py
- After running the above code, the code automates to open Google browser as below
Through above code you can download image with search_term of your choice
Happy Downloading !!