Przeglądaj źródła

[enh] make search type of mediawiki configurable

Noémi Ványi 8 lat temu
rodzic
commit
2db807368c
1 zmienionych plików z 4 dodań i 2 usunięć
  1. 4
    2
      searx/engines/mediawiki.py

+ 4
- 2
searx/engines/mediawiki.py Wyświetl plik

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