We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Wikipedia crash on specific search query
Instance: searx.be
Browser: Chrome Version 84.0.4147.89

Hello,

Not sure whether this is a bug, problem with the instance itself , or my browser, but when I search for certain query e.g. `port dover`, I get an error message:
```
Engines cannot retrieve results:
wikipedia (unexpected crash 'NoneType' object has no attribute 'replace')
```

![Image 6](https://user-images.githubusercontent.com/8424198/88169288-fc8b0380-cc45-11ea-98ea-c1b897b40273.png)



This error doesn't happen if I change the language to Deutsch, Espanol, or other language. Seems like it only happens with English language.  


![Image 2](https://user-images.githubusercontent.com/8424198/88170044-33154e00-cc47-11ea-8560-2711f8323bd6.png)


![Image 3](https://user-images.githubusercontent.com/8424198/88170063-3d374c80-cc47-11ea-9ad6-5bd75e1eaa18.png)



This error doesn't happen with other search query.

![Image 4](https://user-images.githubusercontent.com/8424198/88170309-ad45d280-cc47-11ea-85bc-e7ce87ba76a3.png)


I also test this on other searx instances and the results are mixed. 

No error:
https://searx.ninja
https://search.snopyta.org/
Both are still on 0.16.0

Same error:
https://searx.fmac.xyz
https://searx.xyz/



--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `searx/engines/wikipedia.py`
Content:
```
1 """
2  Wikipedia (Web)
3 
4  @website     https://{language}.wikipedia.org
5  @provide-api yes
6 
7  @using-api   yes
8  @results     JSON
9  @stable      yes
10  @parse       url, infobox
11 """
12 
13 from json import loads
14 from lxml.html import fromstring
15 from searx.url_utils import quote, urlencode
16 from searx.utils import match_language
17 
18 # search-url
19 base_url = u'https://{language}.wikipedia.org/'
20 search_url = base_url + u'w/api.php?'\
21     'action=query'\
22     '&format=json'\
23     '&{query}'\
24     '&prop=extracts|pageimages|pageprops'\
25     '&ppprop=disambiguation'\
26     '&exintro'\
27     '&explaintext'\
28     '&pithumbsize=300'\
29     '&redirects'
30 supported_languages_url = 'https://meta.wikimedia.org/wiki/List_of_Wikipedias'
31 
32 
33 # set language in base_url
34 def url_lang(lang):
35     lang_pre = lang.split('-')[0]
36     if lang_pre == 'all' or lang_pre not in supported_languages and lang_pre not in language_aliases:
37         return 'en'
38     return match_language(lang, supported_languages, language_aliases).split('-')[0]
39 
40 
41 # do search-request
42 def request(query, params):
43     if query.islower():
44         query = u'{0}|{1}'.format(query.decode('utf-8'), query.decode('utf-8').title()).encode('utf-8')
45 
46     params['url'] = search_url.format(query=urlencode({'titles': query}),
47                                       language=url_lang(params['language']))
48 
49     return params
50 
51 
52 # get first meaningful paragraph
53 # this should filter out disambiguation pages and notes above first paragraph
54 # "magic numbers" were obtained by fine tuning
55 def extract_first_paragraph(content, title, image):
56     first_paragraph = None
57 
58     failed_attempts = 0
59     for paragraph in content.split('\n'):
60 
61         starts_with_title = paragraph.lower().find(title.lower(), 0, len(title) + 35)
62         length = len(paragraph)
63 
64         if length >= 200 or (starts_with_title >= 0 and (image or length >= 150)):
65             first_paragraph = paragraph
66             break
67 
68         failed_attempts += 1
69         if failed_attempts > 3:
70             return None
71 
72     return first_paragraph
73 
74 
75 # get response from search-request
76 def response(resp):
77     results = []
78 
79     search_result = loads(resp.text)
80 
81     # wikipedia article's unique id
82     # first valid id is assumed to be the requested article
83     if 'pages' not in search_result['query']:
84         return results
85 
86     for article_id in search_result['query']['pages']:
87         page = search_result['query']['pages'][article_id]
88         if int(article_id) > 0:
89             break
90 
91     if int(article_id) < 0 or 'disambiguation' in page.get('pageprops', {}):
92         return []
93 
94     title = page.get('title')
95 
96     image = page.get('thumbnail')
97     if image:
98         image = image.get('source')
99 
100     extract = page.get('extract')
101 
102     summary = extract_first_paragraph(extract, title, image)
103     summary = summary.replace('() ', '')
104 
105     # link to wikipedia article
106     wikipedia_link = base_url.format(language=url_lang(resp.search_params['language'])) \
107         + 'wiki/' + quote(title.replace(' ', '_').encode('utf8'))
108 
109     results.append({'url': wikipedia_link, 'title': title})
110 
111     results.append({'infobox': title,
112                     'id': wikipedia_link,
113                     'content': summary,
114                     'img_src': image,
115                     'urls': [{'title': 'Wikipedia', 'url': wikipedia_link}]})
116 
117     return results
118 
119 
120 # get supported languages from their site
121 def _fetch_supported_languages(resp):
122     supported_languages = {}
123     dom = fromstring(resp.text)
124     tables = dom.xpath('//table[contains(@class,"sortable")]')
125     for table in tables:
126         # exclude header row
127         trs = table.xpath('.//tr')[1:]
128         for tr in trs:
129             td = tr.xpath('./td')
130             code = td[3].xpath('./a')[0].text
131             name = td[2].xpath('./a')[0].text
132             english_name = td[1].xpath('./a')[0].text
133             articles = int(td[4].xpath('./a/b')[0].text.replace(',', ''))
134             # exclude languages with too few articles
135             if articles >= 100:
136                 supported_languages[code] = {"name": name, "english_name": english_name, "articles": articles}
137 
138     return supported_languages
139
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/searx/engines/wikipedia.py b/searx/engines/wikipedia.py
--- a/searx/engines/wikipedia.py
+++ b/searx/engines/wikipedia.py
@@ -49,29 +49,6 @@
     return params
 
 
-# get first meaningful paragraph
-# this should filter out disambiguation pages and notes above first paragraph
-# "magic numbers" were obtained by fine tuning
-def extract_first_paragraph(content, title, image):
-    first_paragraph = None
-
-    failed_attempts = 0
-    for paragraph in content.split('\n'):
-
-        starts_with_title = paragraph.lower().find(title.lower(), 0, len(title) + 35)
-        length = len(paragraph)
-
-        if length >= 200 or (starts_with_title >= 0 and (image or length >= 150)):
-            first_paragraph = paragraph
-            break
-
-        failed_attempts += 1
-        if failed_attempts > 3:
-            return None
-
-    return first_paragraph
-
-
 # get response from search-request
 def response(resp):
     results = []
@@ -97,10 +74,7 @@
     if image:
         image = image.get('source')
 
-    extract = page.get('extract')
-
-    summary = extract_first_paragraph(extract, title, image)
-    summary = summary.replace('() ', '')
+    summary = page.get('extract', '').split('\n')[0].replace('()', '')
 
     # link to wikipedia article
     wikipedia_link = base_url.format(language=url_lang(resp.search_params['language'])) \

{"golden_diff": "diff --git a/searx/engines/wikipedia.py b/searx/engines/wikipedia.py\n--- a/searx/engines/wikipedia.py\n+++ b/searx/engines/wikipedia.py\n@@ -49,29 +49,6 @@\n     return params\n \n \n-# get first meaningful paragraph\n-# this should filter out disambiguation pages and notes above first paragraph\n-# \"magic numbers\" were obtained by fine tuning\n-def extract_first_paragraph(content, title, image):\n-    first_paragraph = None\n-\n-    failed_attempts = 0\n-    for paragraph in content.split('\\n'):\n-\n-        starts_with_title = paragraph.lower().find(title.lower(), 0, len(title) + 35)\n-        length = len(paragraph)\n-\n-        if length >= 200 or (starts_with_title >= 0 and (image or length >= 150)):\n-            first_paragraph = paragraph\n-            break\n-\n-        failed_attempts += 1\n-        if failed_attempts > 3:\n-            return None\n-\n-    return first_paragraph\n-\n-\n # get response from search-request\n def response(resp):\n     results = []\n@@ -97,10 +74,7 @@\n     if image:\n         image = image.get('source')\n \n-    extract = page.get('extract')\n-\n-    summary = extract_first_paragraph(extract, title, image)\n-    summary = summary.replace('() ', '')\n+    summary = page.get('extract', '').split('\\n')[0].replace('()', '')\n \n     # link to wikipedia article\n     wikipedia_link = base_url.format(language=url_lang(resp.search_params['language'])) \\\n", "issue": "Wikipedia crash on specific search query\nInstance: searx.be\r\nBrowser: Chrome Version 84.0.4147.89\r\n\r\nHello,\r\n\r\nNot sure whether this is a bug, problem with the instance itself , or my browser, but when I search for certain query e.g. `port dover`, I get an error message:\r\n```\r\nEngines cannot retrieve results:\r\nwikipedia (unexpected crash 'NoneType' object has no attribute 'replace')\r\n```\r\n\r\n![Image 6](https://user-images.githubusercontent.com/8424198/88169288-fc8b0380-cc45-11ea-98ea-c1b897b40273.png)\r\n\r\n\r\n\r\nThis error doesn't happen if I change the language to Deutsch, Espanol, or other language. Seems like it only happens with English language.  \r\n\r\n\r\n![Image 2](https://user-images.githubusercontent.com/8424198/88170044-33154e00-cc47-11ea-8560-2711f8323bd6.png)\r\n\r\n\r\n![Image 3](https://user-images.githubusercontent.com/8424198/88170063-3d374c80-cc47-11ea-9ad6-5bd75e1eaa18.png)\r\n\r\n\r\n\r\nThis error doesn't happen with other search query.\r\n\r\n![Image 4](https://user-images.githubusercontent.com/8424198/88170309-ad45d280-cc47-11ea-85bc-e7ce87ba76a3.png)\r\n\r\n\r\nI also test this on other searx instances and the results are mixed. \r\n\r\nNo error:\r\nhttps://searx.ninja\r\nhttps://search.snopyta.org/\r\nBoth are still on 0.16.0\r\n\r\nSame error:\r\nhttps://searx.fmac.xyz\r\nhttps://searx.xyz/\r\n\r\n\n", "before_files": [{"content": "\"\"\"\n Wikipedia (Web)\n\n @website     https://{language}.wikipedia.org\n @provide-api yes\n\n @using-api   yes\n @results     JSON\n @stable      yes\n @parse       url, infobox\n\"\"\"\n\nfrom json import loads\nfrom lxml.html import fromstring\nfrom searx.url_utils import quote, urlencode\nfrom searx.utils import match_language\n\n# search-url\nbase_url = u'https://{language}.wikipedia.org/'\nsearch_url = base_url + u'w/api.php?'\\\n    'action=query'\\\n    '&format=json'\\\n    '&{query}'\\\n    '&prop=extracts|pageimages|pageprops'\\\n    '&ppprop=disambiguation'\\\n    '&exintro'\\\n    '&explaintext'\\\n    '&pithumbsize=300'\\\n    '&redirects'\nsupported_languages_url = 'https://meta.wikimedia.org/wiki/List_of_Wikipedias'\n\n\n# set language in base_url\ndef url_lang(lang):\n    lang_pre = lang.split('-')[0]\n    if lang_pre == 'all' or lang_pre not in supported_languages and lang_pre not in language_aliases:\n        return 'en'\n    return match_language(lang, supported_languages, language_aliases).split('-')[0]\n\n\n# do search-request\ndef request(query, params):\n    if query.islower():\n        query = u'{0}|{1}'.format(query.decode('utf-8'), query.decode('utf-8').title()).encode('utf-8')\n\n    params['url'] = search_url.format(query=urlencode({'titles': query}),\n                                      language=url_lang(params['language']))\n\n    return params\n\n\n# get first meaningful paragraph\n# this should filter out disambiguation pages and notes above first paragraph\n# \"magic numbers\" were obtained by fine tuning\ndef extract_first_paragraph(content, title, image):\n    first_paragraph = None\n\n    failed_attempts = 0\n    for paragraph in content.split('\\n'):\n\n        starts_with_title = paragraph.lower().find(title.lower(), 0, len(title) + 35)\n        length = len(paragraph)\n\n        if length >= 200 or (starts_with_title >= 0 and (image or length >= 150)):\n            first_paragraph = paragraph\n            break\n\n        failed_attempts += 1\n        if failed_attempts > 3:\n            return None\n\n    return first_paragraph\n\n\n# get response from search-request\ndef response(resp):\n    results = []\n\n    search_result = loads(resp.text)\n\n    # wikipedia article's unique id\n    # first valid id is assumed to be the requested article\n    if 'pages' not in search_result['query']:\n        return results\n\n    for article_id in search_result['query']['pages']:\n        page = search_result['query']['pages'][article_id]\n        if int(article_id) > 0:\n            break\n\n    if int(article_id) < 0 or 'disambiguation' in page.get('pageprops', {}):\n        return []\n\n    title = page.get('title')\n\n    image = page.get('thumbnail')\n    if image:\n        image = image.get('source')\n\n    extract = page.get('extract')\n\n    summary = extract_first_paragraph(extract, title, image)\n    summary = summary.replace('() ', '')\n\n    # link to wikipedia article\n    wikipedia_link = base_url.format(language=url_lang(resp.search_params['language'])) \\\n        + 'wiki/' + quote(title.replace(' ', '_').encode('utf8'))\n\n    results.append({'url': wikipedia_link, 'title': title})\n\n    results.append({'infobox': title,\n                    'id': wikipedia_link,\n                    'content': summary,\n                    'img_src': image,\n                    'urls': [{'title': 'Wikipedia', 'url': wikipedia_link}]})\n\n    return results\n\n\n# get supported languages from their site\ndef _fetch_supported_languages(resp):\n    supported_languages = {}\n    dom = fromstring(resp.text)\n    tables = dom.xpath('//table[contains(@class,\"sortable\")]')\n    for table in tables:\n        # exclude header row\n        trs = table.xpath('.//tr')[1:]\n        for tr in trs:\n            td = tr.xpath('./td')\n            code = td[3].xpath('./a')[0].text\n            name = td[2].xpath('./a')[0].text\n            english_name = td[1].xpath('./a')[0].text\n            articles = int(td[4].xpath('./a/b')[0].text.replace(',', ''))\n            # exclude languages with too few articles\n            if articles >= 100:\n                supported_languages[code] = {\"name\": name, \"english_name\": english_name, \"articles\": articles}\n\n    return supported_languages\n", "path": "searx/engines/wikipedia.py"}], "after_files": [{"content": "\"\"\"\n Wikipedia (Web)\n\n @website     https://{language}.wikipedia.org\n @provide-api yes\n\n @using-api   yes\n @results     JSON\n @stable      yes\n @parse       url, infobox\n\"\"\"\n\nfrom json import loads\nfrom lxml.html import fromstring\nfrom searx.url_utils import quote, urlencode\nfrom searx.utils import match_language\n\n# search-url\nbase_url = u'https://{language}.wikipedia.org/'\nsearch_url = base_url + u'w/api.php?'\\\n    'action=query'\\\n    '&format=json'\\\n    '&{query}'\\\n    '&prop=extracts|pageimages|pageprops'\\\n    '&ppprop=disambiguation'\\\n    '&exintro'\\\n    '&explaintext'\\\n    '&pithumbsize=300'\\\n    '&redirects'\nsupported_languages_url = 'https://meta.wikimedia.org/wiki/List_of_Wikipedias'\n\n\n# set language in base_url\ndef url_lang(lang):\n    lang_pre = lang.split('-')[0]\n    if lang_pre == 'all' or lang_pre not in supported_languages and lang_pre not in language_aliases:\n        return 'en'\n    return match_language(lang, supported_languages, language_aliases).split('-')[0]\n\n\n# do search-request\ndef request(query, params):\n    if query.islower():\n        query = u'{0}|{1}'.format(query.decode('utf-8'), query.decode('utf-8').title()).encode('utf-8')\n\n    params['url'] = search_url.format(query=urlencode({'titles': query}),\n                                      language=url_lang(params['language']))\n\n    return params\n\n\n# get response from search-request\ndef response(resp):\n    results = []\n\n    search_result = loads(resp.text)\n\n    # wikipedia article's unique id\n    # first valid id is assumed to be the requested article\n    if 'pages' not in search_result['query']:\n        return results\n\n    for article_id in search_result['query']['pages']:\n        page = search_result['query']['pages'][article_id]\n        if int(article_id) > 0:\n            break\n\n    if int(article_id) < 0 or 'disambiguation' in page.get('pageprops', {}):\n        return []\n\n    title = page.get('title')\n\n    image = page.get('thumbnail')\n    if image:\n        image = image.get('source')\n\n    summary = page.get('extract', '').split('\\n')[0].replace('()', '')\n\n    # link to wikipedia article\n    wikipedia_link = base_url.format(language=url_lang(resp.search_params['language'])) \\\n        + 'wiki/' + quote(title.replace(' ', '_').encode('utf8'))\n\n    results.append({'url': wikipedia_link, 'title': title})\n\n    results.append({'infobox': title,\n                    'id': wikipedia_link,\n                    'content': summary,\n                    'img_src': image,\n                    'urls': [{'title': 'Wikipedia', 'url': wikipedia_link}]})\n\n    return results\n\n\n# get supported languages from their site\ndef _fetch_supported_languages(resp):\n    supported_languages = {}\n    dom = fromstring(resp.text)\n    tables = dom.xpath('//table[contains(@class,\"sortable\")]')\n    for table in tables:\n        # exclude header row\n        trs = table.xpath('.//tr')[1:]\n        for tr in trs:\n            td = tr.xpath('./td')\n            code = td[3].xpath('./a')[0].text\n            name = td[2].xpath('./a')[0].text\n            english_name = td[1].xpath('./a')[0].text\n            articles = int(td[4].xpath('./a/b')[0].text.replace(',', ''))\n            # exclude languages with too few articles\n            if articles >= 100:\n                supported_languages[code] = {\"name\": name, \"english_name\": english_name, \"articles\": articles}\n\n    return supported_languages\n", "path": "searx/engines/wikipedia.py"}]}