-
Notifications
You must be signed in to change notification settings - Fork 0
/
down_image_from_google.py
52 lines (44 loc) · 1.12 KB
/
down_image_from_google.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
42
43
44
45
46
47
48
49
50
51
52
from google_images_download import google_images_download
def downloadimages(query, format="jpg", limit=30, size="medium", aspect_ratio="panoramic", print_urls=True):
"""
aspect_ratio : indique le ration entre la hauteur et la largeur de l'image dont :
- tall
- square
- wide
- panoramic (par défaut)
"""
resp = google_images_download.googleimagesdownload()
arguments = {
"keywords": query,
"format": format,
"limit": limit,
"print_urls": print_urls,
"size": size,
"aspect ratio": aspect_ratio
}
try:
resp.download(arguments)
except FileNotFoundError:
arguments = {
"keywords": query,
"format": format,
"limit": limit,
"print_urls": print_urls,
"size": size,
}
try:
resp.download(arguments)
except:
pass
# searc_queries =[
# 'pizza',
# 'bread',
# 'door',
# 'café'
# ]
searc_queries =[
'hotdog'
]
for query in searc_queries:
downloadimages(query=query, limit=100)
print()