This script downloads images from Google Images based on provided --search
SEARCH_TERM and --amount
AMOUNT.
By default script is running Google Chrome. But You may run the program headless using --headless
flag.
Imges will be saved in folder with SEARCH_TERM name that will be created where google_image_downloader.py is located.
NOTE: If folder named SEARCH_TERM exists in google_image_downloader.py location, script removes it with all content and creates new one.
How to use?
python3 google_image_downloader.py --search SEARCH_TERM --amount N
-
Make sure there is proper chromedriver in chromedriver_folder.
There is already one zip file with chromedriver for MacOS, unzip and done!
If you need different chromedriver, download it here. -
Make sure that dependencies are installed and ready to use (requirements.txt).
-
Run script using Python3 (see examples below).
Examples:
-
Download 30 images of 'snowboard' using headless browser:
python3 google_image_downloader.py --search snowboard --amount 30 --headless
-
Download 5 images of 'apple cortland' without headless mode:
python3 google_image_downloader.py --search apple cortland --amount 5
3 types of flags ready to use:
--search
: determines search term--amount
: determines amount of images to download--headless
: determine headless browser run when provided
Modules used:
selenium
requests
os
shutil
time
sys