[enh] make search type of mediawiki configurable

This commit is contained in:
Noémi Ványi 2017-05-18 21:34:54 +02:00
parent 9ee8e552da
commit 2db807368c
1 changed files with 4 additions and 2 deletions

View File

@ -21,6 +21,7 @@ categories = ['general']
language_support = True language_support = True
paging = True paging = True
number_of_results = 1 number_of_results = 1
search_type = 'nearmatch' # possible values: title, text, nearmatch
# search-url # search-url
base_url = 'https://{language}.wikipedia.org/' base_url = 'https://{language}.wikipedia.org/'
@ -30,7 +31,7 @@ search_postfix = 'w/api.php?action=query'\
'&format=json'\ '&format=json'\
'&sroffset={offset}'\ '&sroffset={offset}'\
'&srlimit={limit}'\ '&srlimit={limit}'\
'&srwhat=nearmatch' # search for a near match in the title '&srwhat={searchtype}' # search for a near match in the title
# do search-request # do search-request
@ -39,7 +40,8 @@ def request(query, params):
string_args = dict(query=urlencode({'srsearch': query}), string_args = dict(query=urlencode({'srsearch': query}),
offset=offset, offset=offset,
limit=number_of_results) limit=number_of_results,
searchtype=search_type)
format_strings = list(Formatter().parse(base_url)) format_strings = list(Formatter().parse(base_url))