From 909424e1e5fc3f7c3a7089d8a4ddae84e56db8dd Mon Sep 17 00:00:00 2001 From: Adam Tauber Date: Mon, 8 Feb 2016 21:51:47 +0100 Subject: [PATCH] [fix] real support of non wikipedia style mediawikis --- searx/engines/mediawiki.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/searx/engines/mediawiki.py b/searx/engines/mediawiki.py index 9fb72e830..ff3fad2d7 100644 --- 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