-
Notifications
You must be signed in to change notification settings - Fork 0
/
scrapegoogleimages.py
41 lines (33 loc) · 1.24 KB
/
scrapegoogleimages.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#%%
# pip install google_images_download
# importing google_images_download module
# from google_images_download import google_images_download
# creating object
response = google_images_download.googleimagesdownload()
search_queries = ['disorganized room']
# update limit
def downloadimages(query):
arguments = {"keywords": query,"format": "jpg", "limit":350,"print_urls": True, "size": "medium", "aspect_ratio": "panoramic",
"chromedriver": "chromedriver.exe" }
try:
response.download(arguments)
# Handling File NotFound Error
except FileNotFoundError:
arguments = {"keywords": query,
"format": "jpg",
"limit":350,
"print_urls":True,
"size": "medium",
"chromedriver": "chromedriver.exe" } # add chromedriver argument
# Providing arguments for the searched query
try:
# Downloading the photos based
# on the given arguments
response.download(arguments)
except:
pass
# Driver Code
for query in search_queries:
downloadimages(query)
print()
#%%