1
0
mirror of https://github.com/searx/searx synced 2024-12-26 19:15:22 +01:00

Fix online dictionaries

This commit is contained in:
Noémi Ványi 2022-07-30 21:54:24 +02:00
parent 05fe2ee093
commit 54697a8705
2 changed files with 11 additions and 12 deletions

View File

@ -17,7 +17,7 @@ about = {
"results": 'HTML',
}
engine_type = 'online_dictionnary'
engine_type = 'online_dictionary'
categories = ['general']
url = 'https://dictzone.com/{from_lang}-{to_lang}-dictionary/{query}'
weight = 100
@ -27,9 +27,7 @@ https_support = True
def request(query, params):
params['url'] = url.format(from_lang=params['from_lang'][2],
to_lang=params['to_lang'][2],
query=params['query'])
params['url'] = url.format(from_lang=params['from_lang'][2], to_lang=params['to_lang'][2], query=params['query'])
return params
@ -51,10 +49,12 @@ def response(resp):
if t.strip():
to_results.append(to_result.text_content())
results.append({
'url': urljoin(resp.url, '?%d' % k),
'title': from_result.text_content(),
'content': '; '.join(to_results)
})
results.append(
{
'url': urljoin(str(resp.url), '?%d' % k),
'title': from_result.text_content(),
'content': '; '.join(to_results),
}
)
return results

View File

@ -5,13 +5,12 @@ import re
from searx.utils import is_valid_lang
from .online import OnlineProcessor
parser_re = re.compile('.*?([a-z]+)-([a-z]+) ([^ ]+)$', re.I)
parser_re = re.compile('.*?([a-z]+)-([a-z]+) (.+)$', re.I)
class OnlineDictionaryProcessor(OnlineProcessor):
engine_type = 'online_dictionnary'
engine_type = 'online_dictionary'
def get_params(self, search_query, engine_category):
params = super().get_params(search_query, engine_category)