diff options
| author | Markus Heiser <markus.heiser@darmarIT.de> | 2019-12-24 15:42:05 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-12-24 15:42:05 +0100 |
| commit | 38dad2e8e3b100711afe3ae942aaed5111841cd6 (patch) | |
| tree | 51f1a35121155010411aa5970ef06aff80adf741 /searx/engines/wikipedia.py | |
| parent | 0ae86cd1685d244c83a6080a7816365096ab06f8 (diff) | |
| parent | a395fb4a8d030d5b8fde496d2ae722bc034d3e32 (diff) | |
Merge branch 'master' into ne/fix-infinite_scroll-with-vim_bindings
Diffstat (limited to 'searx/engines/wikipedia.py')
| -rw-r--r-- | searx/engines/wikipedia.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/searx/engines/wikipedia.py b/searx/engines/wikipedia.py index 4dae735d1..a216ba886 100644 --- a/searx/engines/wikipedia.py +++ b/searx/engines/wikipedia.py @@ -21,7 +21,8 @@ search_url = base_url + u'w/api.php?'\ 'action=query'\ '&format=json'\ '&{query}'\ - '&prop=extracts|pageimages'\ + '&prop=extracts|pageimages|pageprops'\ + '&ppprop=disambiguation'\ '&exintro'\ '&explaintext'\ '&pithumbsize=300'\ @@ -79,12 +80,15 @@ def response(resp): # wikipedia article's unique id # first valid id is assumed to be the requested article + if 'pages' not in search_result['query']: + return results + for article_id in search_result['query']['pages']: page = search_result['query']['pages'][article_id] if int(article_id) > 0: break - if int(article_id) < 0: + if int(article_id) < 0 or 'disambiguation' in page.get('pageprops', {}): return [] title = page.get('title') @@ -96,6 +100,7 @@ def response(resp): extract = page.get('extract') summary = extract_first_paragraph(extract, title, image) + summary = summary.replace('() ', '') # link to wikipedia article wikipedia_link = base_url.format(language=url_lang(resp.search_params['language'])) \ |