logo

searx

My custom branche(s) on searx, a meta-search engine
commit: 909424e1e5fc3f7c3a7089d8a4ddae84e56db8dd
parent: 250777e8a7719a90549f26de14dfec76a0111985
Author: Adam Tauber <asciimoo@gmail.com>
Date:   Mon,  8 Feb 2016 21:51:47 +0100

[fix] real support of non wikipedia style mediawikis

Diffstat:

Msearx/engines/mediawiki.py19+++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/searx/engines/mediawiki.py b/searx/engines/mediawiki.py @@ -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