diff options
author | Adam Tauber <asciimoo@gmail.com> | 2016-02-09 21:21:59 +0100 |
---|---|---|
committer | Adam Tauber <asciimoo@gmail.com> | 2016-02-09 21:21:59 +0100 |
commit | b5061b5f0fd2e3058af60038a47676ad26c671e6 (patch) | |
tree | 99f19260bb9fac3cc09b6d00b1ac6cc1ab2137dd /searx/engines/mediawiki.py | |
parent | 909424e1e5fc3f7c3a7089d8a4ddae84e56db8dd (diff) | |
download | searxng-b5061b5f0fd2e3058af60038a47676ad26c671e6.tar.gz searxng-b5061b5f0fd2e3058af60038a47676ad26c671e6.zip |
[fix] restrict wikipedia queries to the titles to avoid irrelevant results
Diffstat (limited to 'searx/engines/mediawiki.py')
-rw-r--r-- | searx/engines/mediawiki.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/searx/engines/mediawiki.py b/searx/engines/mediawiki.py index ff3fad2d7..26d3720d9 100644 --- a/searx/engines/mediawiki.py +++ b/searx/engines/mediawiki.py @@ -27,10 +27,10 @@ base_url = 'https://{language}.wikipedia.org/' search_postfix = 'w/api.php?action=query'\ '&list=search'\ '&{query}'\ - '&srprop=timestamp'\ '&format=json'\ '&sroffset={offset}'\ - '&srlimit={limit}' + '&srlimit={limit}'\ + '&srwhat=nearmatch' # search for a near match in the title # do search-request @@ -74,6 +74,8 @@ def response(resp): # parse results for result in search_results['query']['search']: + if result.get('snippet', '').startswith('#REDIRECT'): + continue url = base_url.format(language=resp.search_params['language']) +\ 'wiki/' + quote(result['title'].replace(' ', '_').encode('utf-8')) |