2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

google_images_download

Posted at

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.png

image.png

# 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

image.png

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()

image.png

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?