1
0
mirror of https://github.com/searxng/searxng.git synced 2024-11-19 02:40:11 +01:00

[fix] real support of non wikipedia style mediawikis

This commit is contained in:
Adam Tauber 2016-02-08 21:51:47 +01:00
parent 250777e8a7
commit 909424e1e5

View File

@ -24,13 +24,13 @@ number_of_results = 1
# search-url # search-url
base_url = 'https://{language}.wikipedia.org/' base_url = 'https://{language}.wikipedia.org/'
search_url = base_url + 'w/api.php?action=query'\ search_postfix = 'w/api.php?action=query'\
'&list=search'\ '&list=search'\
'&{query}'\ '&{query}'\
'&srprop=timestamp'\ '&srprop=timestamp'\
'&format=json'\ '&format=json'\
'&sroffset={offset}'\ '&sroffset={offset}'\
'&srlimit={limit}' # noqa '&srlimit={limit}'
# do search-request # do search-request
@ -48,12 +48,15 @@ def request(query, params):
else: else:
language = params['language'].split('_')[0] 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 string_args['language'] = language
# write search-language back to params, required in response # write search-language back to params, required in response
params['language'] = language params['language'] = language
search_url = base_url + search_postfix
params['url'] = search_url.format(**string_args) params['url'] = search_url.format(**string_args)
return params return params