on master help sign in
Merge pull request #1686 from MarcAbonce/wiki_infobox_fixes

Infobox fixes

commit3e14bf4d2786ce5f2a61684cf16744700e670e60 authorMarkus Heiser <markus.heiser@darmarIT.de> dateMon 23 Dec 2019, 12:31 (7 years ago) parent34ad3d6495ae59
2 files changed+9−7
searx/engines/wikipedia.py+4−2 searx/webapp.py+5−5
searx/engines/wikipedia.py+4−2
@@ -21,7 +21,8 @@ search_url = base_url + u'w/api.php?'\
2121 'action=query'\
2222 '&format=json'\
2323 '&{query}'\
24− '&prop=extracts|pageimages'\
24+ '&prop=extracts|pageimages|pageprops'\
25+ '&ppprop=disambiguation'\
2526 '&exintro'\
2627 '&explaintext'\
2728 '&pithumbsize=300'\
@@ -87,7 +88,7 @@ def response(resp):
8788 if int(article_id) > 0:
8889 break
8990
90− if int(article_id) < 0:
91+ if int(article_id) < 0 or 'disambiguation' in page.get('pageprops', {}):
9192 return []
9293
9394 title = page.get('title')
@@ -99,6 +100,7 @@ def response(resp):
99100 extract = page.get('extract')
100101
101102 summary = extract_first_paragraph(extract, title, image)
103+ summary = summary.replace('() ', '')
102104
103105 # link to wikipedia article
104106 wikipedia_link = base_url.format(language=url_lang(resp.search_params['language'])) \
searx/webapp.py+5−5
@@ -606,11 +606,11 @@ def index():
606606 # HTML output format
607607
608608 # suggestions: use RawTextQuery to get the suggestion URLs with the same bang
609− suggestion_urls = map(lambda suggestion: {
610− 'url': raw_text_query.changeSearchQuery(suggestion).getFullQuery(),
611− 'title': suggestion
612− },
613− result_container.suggestions)
609+ suggestion_urls = list(map(lambda suggestion: {
610+ 'url': raw_text_query.changeSearchQuery(suggestion).getFullQuery(),
611+ 'title': suggestion
612+ },
613+ result_container.suggestions))
614614
615615 correction_urls = list(map(lambda correction: {
616616 'url': raw_text_query.changeSearchQuery(correction).getFullQuery(),