mirror of https://github.com/searxng/searxng.git
[fix] real support of non wikipedia style mediawikis
This commit is contained in:
parent
250777e8a7
commit
909424e1e5
|
@ -24,13 +24,13 @@ number_of_results = 1
|
|||
|
||||
# search-url
|
||||
base_url = 'https://{language}.wikipedia.org/'
|
||||
search_url = base_url + 'w/api.php?action=query'\
|
||||
'&list=search'\
|
||||
'&{query}'\
|
||||
'&srprop=timestamp'\
|
||||
'&format=json'\
|
||||
'&sroffset={offset}'\
|
||||
'&srlimit={limit}' # noqa
|
||||
search_postfix = 'w/api.php?action=query'\
|
||||
'&list=search'\
|
||||
'&{query}'\
|
||||
'&srprop=timestamp'\
|
||||
'&format=json'\
|
||||
'&sroffset={offset}'\
|
||||
'&srlimit={limit}'
|
||||
|
||||
|
||||
# do search-request
|
||||
|
@ -48,12 +48,15 @@ def request(query, params):
|
|||
else:
|
||||
language = params['language'].split('_')[0]
|
||||
|
||||
if len(format_strings) > 1:
|
||||
# format_string [('https://', 'language', '', None), ('.wikipedia.org/', None, None, None)]
|
||||
if any(x[1] == 'language' for x in format_strings):
|
||||
string_args['language'] = language
|
||||
|
||||
# write search-language back to params, required in response
|
||||
params['language'] = language
|
||||
|
||||
search_url = base_url + search_postfix
|
||||
|
||||
params['url'] = search_url.format(**string_args)
|
||||
|
||||
return params
|
||||
|
|
Loading…
Reference in New Issue