prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Bug: microsoft academic engine
  **Version of SearXNG, commit number if you are using on master branch and stipulate if you forked SearXNG**
  Repository: https://github.com/tiekoetter/searxng
  Branch: master
  Version: 1.0.0-972-93548243
  <!-- Check if these values are correct -->
  
  **How did you install SearXNG?**
  <!-- Did you install SearXNG using the official wiki or using searxng-docker
  or manually by executing the searx/webapp.py file? -->
  **What happened?**
  <!-- A clear and concise description of what the bug is. -->
  
  **How To Reproduce**
  <!-- How can we reproduce this issue? (as minimally and as precisely as possible) -->
  
  **Expected behavior**
  <!-- A clear and concise description of what you expected to happen. -->
  
  **Screenshots & Logs**
  <!-- If applicable, add screenshots, logs to help explain your problem. -->
  
  **Additional context**
  <!-- Add any other context about the problem here. -->
  
  **Technical report**
  
  Error
    * Error: httpx.TimeoutException
    * Percentage: 50
    * Parameters: `(None, None, None)`
    * File name: `searx/search/processors/online.py:97`
    * Function: `_send_http_request`
    * Code: `response = req(params['url'], **request_args)`
  
  
  
  --- 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/microsoft_academic.py`
  Content:
  ```
  1 # SPDX-License-Identifier: AGPL-3.0-or-later
  2 """
  3  Microsoft Academic (Science)
  4 """
  5 
  6 from json import dumps, loads
  7 from searx.utils import html_to_text
  8 
  9 # about
  10 about = {
  11     "website": 'https://academic.microsoft.com',
  12     "wikidata_id": 'Q28136779',
  13     "official_api_documentation": 'http://ma-graph.org/',
  14     "use_official_api": False,
  15     "require_api_key": False,
  16     "results": 'JSON',
  17 }
  18 
  19 categories = ['images']
  20 paging = True
  21 search_url = 'https://academic.microsoft.com/api/search'
  22 _paper_url = 'https://academic.microsoft.com/paper/{id}/reference'
  23 
  24 
  25 def request(query, params):
  26     params['url'] = search_url
  27     params['method'] = 'POST'
  28     params['headers']['content-type'] = 'application/json; charset=utf-8'
  29     params['data'] = dumps({
  30         'query': query,
  31         'queryExpression': '',
  32         'filters': [],
  33         'orderBy': 0,
  34         'skip': (params['pageno'] - 1) * 10,
  35         'sortAscending': True,
  36         'take': 10,
  37         'includeCitationContexts': False,
  38         'profileId': '',
  39     })
  40 
  41     return params
  42 
  43 
  44 def response(resp):
  45     results = []
  46     response_data = loads(resp.text)
  47     if not response_data:
  48         return results
  49 
  50     for result in response_data['pr']:
  51         if 'dn' not in result['paper']:
  52             continue
  53 
  54         title = result['paper']['dn']
  55         content = _get_content(result['paper'])
  56         url = _paper_url.format(id=result['paper']['id'])
  57         results.append({
  58             'url': url,
  59             'title': html_to_text(title),
  60             'content': html_to_text(content),
  61         })
  62 
  63     return results
  64 
  65 
  66 def _get_content(result):
  67     if 'd' in result:
  68         content = result['d']
  69         if len(content) > 300:
  70             return content[:300] + '...'
  71         return content
  72 
  73     return ''
  74
  ```
  --- 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()
  
  ```
  
golden_diff: diff --git a/searx/engines/microsoft_academic.py b/searx/engines/microsoft_academic.py
  --- a/searx/engines/microsoft_academic.py
  +++ b/searx/engines/microsoft_academic.py
  @@ -47,7 +47,7 @@
       if not response_data:
           return results
   
  -    for result in response_data['pr']:
  +    for result in response_data.get('pr', {}):
           if 'dn' not in result['paper']:
               continue
  
verification_info: {"golden_diff": "diff --git a/searx/engines/microsoft_academic.py b/searx/engines/microsoft_academic.py\n--- a/searx/engines/microsoft_academic.py\n+++ b/searx/engines/microsoft_academic.py\n@@ -47,7 +47,7 @@\n     if not response_data:\n         return results\n \n-    for result in response_data['pr']:\n+    for result in response_data.get('pr', {}):\n         if 'dn' not in result['paper']:\n             continue\n", "issue": "Bug: microsoft academic engine\n**Version of SearXNG, commit number if you are using on master branch and stipulate if you forked SearXNG**\r\nRepository: https://github.com/tiekoetter/searxng\r\nBranch: master\r\nVersion: 1.0.0-972-93548243\r\n<!-- Check if these values are correct -->\r\n\r\n**How did you install SearXNG?**\r\n<!-- Did you install SearXNG using the official wiki or using searxng-docker\r\nor manually by executing the searx/webapp.py file? -->\r\n**What happened?**\r\n<!-- A clear and concise description of what the bug is. -->\r\n\r\n**How To Reproduce**\r\n<!-- How can we reproduce this issue? (as minimally and as precisely as possible) -->\r\n\r\n**Expected behavior**\r\n<!-- A clear and concise description of what you expected to happen. -->\r\n\r\n**Screenshots & Logs**\r\n<!-- If applicable, add screenshots, logs to help explain your problem. -->\r\n\r\n**Additional context**\r\n<!-- Add any other context about the problem here. -->\r\n\r\n**Technical report**\r\n\r\nError\r\n  * Error: httpx.TimeoutException\r\n  * Percentage: 50\r\n  * Parameters: `(None, None, None)`\r\n  * File name: `searx/search/processors/online.py:97`\r\n  * Function: `_send_http_request`\r\n  * Code: `response = req(params['url'], **request_args)`\r\n\r\n\n", "before_files": [{"content": "# SPDX-License-Identifier: AGPL-3.0-or-later\n\"\"\"\n Microsoft Academic (Science)\n\"\"\"\n\nfrom json import dumps, loads\nfrom searx.utils import html_to_text\n\n# about\nabout = {\n    \"website\": 'https://academic.microsoft.com',\n    \"wikidata_id\": 'Q28136779',\n    \"official_api_documentation\": 'http://ma-graph.org/',\n    \"use_official_api\": False,\n    \"require_api_key\": False,\n    \"results\": 'JSON',\n}\n\ncategories = ['images']\npaging = True\nsearch_url = 'https://academic.microsoft.com/api/search'\n_paper_url = 'https://academic.microsoft.com/paper/{id}/reference'\n\n\ndef request(query, params):\n    params['url'] = search_url\n    params['method'] = 'POST'\n    params['headers']['content-type'] = 'application/json; charset=utf-8'\n    params['data'] = dumps({\n        'query': query,\n        'queryExpression': '',\n        'filters': [],\n        'orderBy': 0,\n        'skip': (params['pageno'] - 1) * 10,\n        'sortAscending': True,\n        'take': 10,\n        'includeCitationContexts': False,\n        'profileId': '',\n    })\n\n    return params\n\n\ndef response(resp):\n    results = []\n    response_data = loads(resp.text)\n    if not response_data:\n        return results\n\n    for result in response_data['pr']:\n        if 'dn' not in result['paper']:\n            continue\n\n        title = result['paper']['dn']\n        content = _get_content(result['paper'])\n        url = _paper_url.format(id=result['paper']['id'])\n        results.append({\n            'url': url,\n            'title': html_to_text(title),\n            'content': html_to_text(content),\n        })\n\n    return results\n\n\ndef _get_content(result):\n    if 'd' in result:\n        content = result['d']\n        if len(content) > 300:\n            return content[:300] + '...'\n        return content\n\n    return ''\n", "path": "searx/engines/microsoft_academic.py"}], "after_files": [{"content": "# SPDX-License-Identifier: AGPL-3.0-or-later\n\"\"\"\n Microsoft Academic (Science)\n\"\"\"\n\nfrom json import dumps, loads\nfrom searx.utils import html_to_text\n\n# about\nabout = {\n    \"website\": 'https://academic.microsoft.com',\n    \"wikidata_id\": 'Q28136779',\n    \"official_api_documentation\": 'http://ma-graph.org/',\n    \"use_official_api\": False,\n    \"require_api_key\": False,\n    \"results\": 'JSON',\n}\n\ncategories = ['images']\npaging = True\nsearch_url = 'https://academic.microsoft.com/api/search'\n_paper_url = 'https://academic.microsoft.com/paper/{id}/reference'\n\n\ndef request(query, params):\n    params['url'] = search_url\n    params['method'] = 'POST'\n    params['headers']['content-type'] = 'application/json; charset=utf-8'\n    params['data'] = dumps({\n        'query': query,\n        'queryExpression': '',\n        'filters': [],\n        'orderBy': 0,\n        'skip': (params['pageno'] - 1) * 10,\n        'sortAscending': True,\n        'take': 10,\n        'includeCitationContexts': False,\n        'profileId': '',\n    })\n\n    return params\n\n\ndef response(resp):\n    results = []\n    response_data = loads(resp.text)\n    if not response_data:\n        return results\n\n    for result in response_data.get('pr', {}):\n        if 'dn' not in result['paper']:\n            continue\n\n        title = result['paper']['dn']\n        content = _get_content(result['paper'])\n        url = _paper_url.format(id=result['paper']['id'])\n        results.append({\n            'url': url,\n            'title': html_to_text(title),\n            'content': html_to_text(content),\n        })\n\n    return results\n\n\ndef _get_content(result):\n    if 'd' in result:\n        content = result['d']\n        if len(content) > 300:\n            return content[:300] + '...'\n        return content\n\n    return ''\n", "path": "searx/engines/microsoft_academic.py"}]}