Added an extra layer of exception handling to image retrieval.

This commit is contained in:
th3r00t
2021-07-24 11:53:12 -04:00
parent efa5c057e4
commit 8405fbed19
2 changed files with 5 additions and 2 deletions

View File

@@ -21,7 +21,10 @@ class DuckDuckGo:
query = query.string
except AttributeError:
query = query
search_result = requests.get(self.url + query + _key)
try:
search_result = requests.get(self.url + query + _key)
except Error as e:
return False
try:
image_result = search_result.json()["Image"]
except ValueError: