summaryrefslogtreecommitdiff
path: root/searx/engines/yacy.py
diff options
context:
space:
mode:
authorNoémi Ványi <sitbackandwait@gmail.com>2020-10-09 15:05:13 +0200
committerNoémi Ványi <sitbackandwait@gmail.com>2020-10-09 15:06:05 +0200
commit72c7fd25fe1f49d27ce7725bb50eaee58d7e009f (patch)
tree158ddd90c1a37ac756edfea278e2a44c498e15e9 /searx/engines/yacy.py
parenta05c660e3036ad8d02072fc6731af54c2ed6151c (diff)
Add yacy improvements: HTTP digest auth, category checking
Diffstat (limited to 'searx/engines/yacy.py')
-rw-r--r--searx/engines/yacy.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/searx/engines/yacy.py b/searx/engines/yacy.py
index daa151082..6f7ab759f 100644
--- a/searx/engines/yacy.py
+++ b/searx/engines/yacy.py
@@ -16,6 +16,8 @@ from json import loads
from dateutil import parser
from urllib.parse import urlencode
+from requests.auth import HTTPDigestAuth
+
from searx.utils import html_to_text
# engine dependent config
@@ -23,6 +25,8 @@ categories = ['general', 'images'] # TODO , 'music', 'videos', 'files'
paging = True
language_support = True
number_of_results = 5
+http_digest_auth_user = ""
+http_digest_auth_pass = ""
# search-url
base_url = 'http://localhost:8090'
@@ -51,6 +55,9 @@ def request(query, params):
limit=number_of_results,
search_type=search_type)
+ if http_digest_auth_user and http_digest_auth_pass:
+ params['auth'] = HTTPDigestAuth(http_digest_auth_user, http_digest_auth_pass)
+
# add language tag if specified
if params['language'] != 'all':
params['url'] += '&lr=lang_' + params['language'].split('-')[0]
@@ -75,7 +82,7 @@ def response(resp):
for result in search_results[0].get('items', []):
# parse image results
- if result.get('image') and result.get('width') and result.get('height'):
+ if resp.search_params.get('category') == 'images':
result_url = ''
if 'url' in result:
@@ -104,5 +111,4 @@ def response(resp):
# TODO parse video, audio and file results
- # return results
return results