summaryrefslogtreecommitdiff
path: root/searx/engines/duckduckgo_images.py
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2020-11-26 17:22:54 +0100
committerAlexandre Flament <alex@al-f.net>2020-12-03 10:22:48 +0100
commit64cccae99e625f3ebd879f94797decd0d824608d (patch)
tree7ef098d4630c5416aad58f0d3ce5abb27390423f /searx/engines/duckduckgo_images.py
parentad72803ed98760b2a95690dea3b95eacc670427c (diff)
downloadsearxng-64cccae99e625f3ebd879f94797decd0d824608d.tar.gz
searxng-64cccae99e625f3ebd879f94797decd0d824608d.zip
[mod] various engines: use eval_xpath* functions and searx.exceptions.*
Engine list: ahmia, duckduckgo_images, elasticsearch, google, google_images, google_videos, youtube_api
Diffstat (limited to 'searx/engines/duckduckgo_images.py')
-rw-r--r--searx/engines/duckduckgo_images.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/searx/engines/duckduckgo_images.py b/searx/engines/duckduckgo_images.py
index 438a8d54c..009f81cca 100644
--- a/searx/engines/duckduckgo_images.py
+++ b/searx/engines/duckduckgo_images.py
@@ -15,6 +15,7 @@
from json import loads
from urllib.parse import urlencode
+from searx.exceptions import SearxEngineAPIException
from searx.engines.duckduckgo import get_region_code
from searx.engines.duckduckgo import _fetch_supported_languages, supported_languages_url # NOQA # pylint: disable=unused-import
from searx.poolrequests import get
@@ -37,7 +38,7 @@ def get_vqd(query, headers):
res = get(query_url, headers=headers)
content = res.text
if content.find('vqd=\'') == -1:
- raise Exception('Request failed')
+ raise SearxEngineAPIException('Request failed')
vqd = content[content.find('vqd=\'') + 5:]
vqd = vqd[:vqd.find('\'')]
return vqd
@@ -71,10 +72,7 @@ def response(resp):
results = []
content = resp.text
- try:
- res_json = loads(content)
- except:
- raise Exception('Cannot parse results')
+ res_json = loads(content)
# parse results
for result in res_json['results']: