Skip to content

Instantly share code, notes, and snippets.

@slavakurilyak
Created December 11, 2019 17:59
Show Gist options
  • Save slavakurilyak/2368d5260253897a1f495182b4f24fbe to your computer and use it in GitHub Desktop.
Save slavakurilyak/2368d5260253897a1f495182b4f24fbe to your computer and use it in GitHub Desktop.
Scrape Google Images
# Scrape Images From Google
#
# Inspiration: https://github.com/DtCarrot/sg-food-ml
import os
import time
from google_images_download import google_images_download
no_images_per_search = 1000 # Scrape 1,000 images per search
response = google_images_download.googleimagesdownload()
def scrape_images(keyword_list):
for keyword in keyword_list:
arguments = {
"keywords": keyword,
"limit": no_images_per_search,
"print_urls": True,
"chromedriver": "/usr/local/bin/chromedriver"
}
paths = response.download(arguments)
time.sleep(5) # Sleep for 5 seconds
google_search_dict = {
'1': 'dog OR canidae',
'2': 'cat OR felidae',
}
google_search_list = google_search_dict.values()
scrape_images(google_search_list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment