Reference
(https://github.com/hardikvasa/google-images-download#troubleshooting-errors-issues)
Library
import os
from google_images_download import google_images_download
import matplotlib.pyplot as plt
%matplotlib inline
Sample Code
# keyws = 'cats with mustaches'
# keyws = 'sky'
keyws = '天丼'
limit = 10
chromedriver = '/content/gdrive/xxx/chromedriver'
offset = None # how many links to skip
color_type = None # color type you want to apply to the images.
# [full-color, black-and-white, transparent]
size = None #relative size of the image to be downloaded.
#[large, medium, icon, >400*300, >640*480, >800*600,
# >1024*768, >2MP, >4MP, >6MP, >8MP, >10MP, >12MP, >15MP, >20MP, >40MP, >70MP]
output_directory = '/content/gdrive/My Drive/xxx/images'
usage_rights = None #Very important! Check the doc
arguments = {
"keywords": keyws,
"limit": limit,
"chromedriver": chromedriver,
"offset": offset,
"color_type": color_type,
"size": size,
# 'output_directory': output_directory,
"usage_rights": usage_rights
} #creating list of arguments
response = google_images_download.googleimagesdownload() #class instantiation
response.download(arguments)
# image_path = '/content/gdrive/My Drive/.../'
image_path = '/content/downloads/'
dataset = [img_name for img_name in os.listdir(image_path + keyws + '/')]
dataset[:10] #Peek the first ten
plt.figure(figsize= (5, 3))
plt.imshow(plt.imread(image_path + keyws + '/' + dataset[0] ) )
plt.grid(b=None) #remove grid
plt.xticks([])
plt.yticks([])
plt.show()
plt.figure(figsize= (5, 3))
plt.imshow(plt.imread(image_path + keyws + '/' + dataset[3] ) )
plt.grid(b=None) #remove grid
plt.xticks([])
plt.yticks([])
plt.show()