Update app.py
Browse files
app.py
CHANGED
@@ -81,22 +81,22 @@ def search_google_images(query, num_images=1):
|
|
81 |
"key": api_key
|
82 |
}
|
83 |
).json()
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
|
101 |
if 'items' in result:
|
102 |
image_urls = []
|
|
|
81 |
"key": api_key
|
82 |
}
|
83 |
).json()
|
84 |
+
else:
|
85 |
+
with requests_proxy.ProxyManager(proxies) as proxy_manager:
|
86 |
+
result = proxy_manager.get(
|
87 |
+
f"https://www.googleapis.com/customsearch/v1",
|
88 |
+
params={
|
89 |
+
"q": query,
|
90 |
+
"cx": cse_id,
|
91 |
+
"searchType": "image",
|
92 |
+
"num": num_images * 3,
|
93 |
+
"safe": 'off',
|
94 |
+
"imgSize": 'HUGE',
|
95 |
+
"imgType": 'photo',
|
96 |
+
"rights": 'cc_publicdomain|cc_attribute|cc_sharealike',
|
97 |
+
"key": api_key
|
98 |
+
}
|
99 |
+
).json()
|
100 |
|
101 |
if 'items' in result:
|
102 |
image_urls = []
|