Created
December 11, 2019 17:59
-
-
Save slavakurilyak/2368d5260253897a1f495182b4f24fbe to your computer and use it in GitHub Desktop.
Scrape Google Images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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