prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Updating languages of qwant is broken
  The URL used for retrieving available languages has gone:
  
  ```
      engines_languages = fetch_supported_languages()
    File "/home/runner/work/searx/searx/./searx_extra/update/update_languages.py", line 30, in fetch_supported_languages
      engines_languages[engine_name] = engines[engine_name].fetch_supported_languages()
    File "/home/runner/work/searx/searx/searx/engines/__init__.py", line 141, in <lambda>
      lambda: engine._fetch_supported_languages(get(engine.supported_languages_url, headers=headers)))
    File "/home/runner/work/searx/searx/searx/poolrequests.py", line 209, in get
      return request('get', url, **kwargs)
    File "/home/runner/work/searx/searx/searx/poolrequests.py", line 202, in request
      raise_for_httperror(response)
    File "/home/runner/work/searx/searx/searx/raise_for_httperror.py", line 66, in raise_for_httperror
      resp.raise_for_status()
    File "/home/runner/work/searx/searx/local/py3/lib/python3.9/site-packages/requests/models.py", line 943, in raise_for_status
      raise HTTPError(http_error_msg, response=self)
  requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://www.qwant.com/region
  ```
  
  Full run: https://github.com/searx/searx/runs/2487497774?check_suite_focus=true
  
  @MarcAbonce If you have time could you please look into it? Or at least give some pointers how it can be fixed?
  
  --- 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/qwant.py`
  Content:
  ```
  1 # SPDX-License-Identifier: AGPL-3.0-or-later
  2 """
  3  Qwant (Web, Images, News, Social)
  4 """
  5 
  6 from datetime import datetime
  7 from json import loads
  8 from urllib.parse import urlencode
  9 from searx.utils import html_to_text, match_language
  10 from searx.exceptions import SearxEngineAPIException, SearxEngineCaptchaException
  11 from searx.raise_for_httperror import raise_for_httperror
  12 
  13 # about
  14 about = {
  15     "website": 'https://www.qwant.com/',
  16     "wikidata_id": 'Q14657870',
  17     "official_api_documentation": None,
  18     "use_official_api": True,
  19     "require_api_key": False,
  20     "results": 'JSON',
  21 }
  22 
  23 # engine dependent config
  24 categories = []
  25 paging = True
  26 supported_languages_url = 'https://qwant.com/region'
  27 
  28 category_to_keyword = {'general': 'web',
  29                        'images': 'images',
  30                        'news': 'news'}
  31 
  32 # search-url
  33 url = 'https://api.qwant.com/api/search/{keyword}?count=10&offset={offset}&f=&{query}&t={keyword}&uiv=4'
  34 
  35 
  36 # do search-request
  37 def request(query, params):
  38     offset = (params['pageno'] - 1) * 10
  39 
  40     if categories[0] and categories[0] in category_to_keyword:
  41 
  42         params['url'] = url.format(keyword=category_to_keyword[categories[0]],
  43                                    query=urlencode({'q': query}),
  44                                    offset=offset)
  45     else:
  46         params['url'] = url.format(keyword='web',
  47                                    query=urlencode({'q': query}),
  48                                    offset=offset)
  49 
  50     # add language tag
  51     if params['language'] != 'all':
  52         language = match_language(params['language'], supported_languages, language_aliases)
  53         params['url'] += '&locale=' + language.replace('-', '_').lower()
  54 
  55     params['headers']['User-Agent'] = 'Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0'
  56     params['raise_for_httperror'] = False
  57     return params
  58 
  59 
  60 # get response from search-request
  61 def response(resp):
  62     results = []
  63 
  64     # According to https://www.qwant.com/js/app.js
  65     if resp.status_code == 429:
  66         raise SearxEngineCaptchaException()
  67 
  68     # raise for other errors
  69     raise_for_httperror(resp)
  70 
  71     # load JSON result
  72     search_results = loads(resp.text)
  73 
  74     # check for an API error
  75     if search_results.get('status') != 'success':
  76         raise SearxEngineAPIException('API error ' + str(search_results.get('error', '')))
  77 
  78     # return empty array if there are no results
  79     if 'data' not in search_results:
  80         return []
  81 
  82     data = search_results.get('data', {})
  83 
  84     res = data.get('result', {})
  85 
  86     # parse results
  87     for result in res.get('items', {}):
  88 
  89         title = html_to_text(result['title'])
  90         res_url = result['url']
  91         content = html_to_text(result['desc'])
  92 
  93         if category_to_keyword.get(categories[0], '') == 'web':
  94             results.append({'title': title,
  95                             'content': content,
  96                             'url': res_url})
  97 
  98         elif category_to_keyword.get(categories[0], '') == 'images':
  99             thumbnail_src = result['thumbnail']
  100             img_src = result['media']
  101             results.append({'template': 'images.html',
  102                             'url': res_url,
  103                             'title': title,
  104                             'content': '',
  105                             'thumbnail_src': thumbnail_src,
  106                             'img_src': img_src})
  107 
  108         elif category_to_keyword.get(categories[0], '') == 'news':
  109             published_date = datetime.fromtimestamp(result['date'], None)
  110             media = result.get('media', [])
  111             if len(media) > 0:
  112                 img_src = media[0].get('pict', {}).get('url', None)
  113             else:
  114                 img_src = None
  115             results.append({'url': res_url,
  116                             'title': title,
  117                             'publishedDate': published_date,
  118                             'content': content,
  119                             'img_src': img_src})
  120 
  121     return results
  122 
  123 
  124 # get supported languages from their site
  125 def _fetch_supported_languages(resp):
  126     # list of regions is embedded in page as a js object
  127     response_text = resp.text
  128     response_text = response_text[response_text.find('regionalisation'):]
  129     response_text = response_text[response_text.find('{'):response_text.find(');')]
  130 
  131     regions_json = loads(response_text)
  132 
  133     supported_languages = {}
  134     for lang in regions_json['languages'].values():
  135         for country in lang['countries']:
  136             lang_code = "{lang}-{country}".format(lang=lang['code'], country=country)
  137             supported_languages[lang_code] = {'name': lang['name']}
  138 
  139     return supported_languages
  140
  ```
  --- 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/qwant.py b/searx/engines/qwant.py
  --- a/searx/engines/qwant.py
  +++ b/searx/engines/qwant.py
  @@ -23,7 +23,7 @@
   # engine dependent config
   categories = []
   paging = True
  -supported_languages_url = 'https://qwant.com/region'
  +supported_languages_url = about['website']
   
   category_to_keyword = {'general': 'web',
                          'images': 'images',
  @@ -125,15 +125,15 @@
   def _fetch_supported_languages(resp):
       # list of regions is embedded in page as a js object
       response_text = resp.text
  -    response_text = response_text[response_text.find('regionalisation'):]
  -    response_text = response_text[response_text.find('{'):response_text.find(');')]
  +    response_text = response_text[response_text.find('INITIAL_PROPS'):]
  +    response_text = response_text[response_text.find('{'):response_text.find('</script>')]
   
       regions_json = loads(response_text)
   
  -    supported_languages = {}
  -    for lang in regions_json['languages'].values():
  -        for country in lang['countries']:
  -            lang_code = "{lang}-{country}".format(lang=lang['code'], country=country)
  -            supported_languages[lang_code] = {'name': lang['name']}
  +    supported_languages = []
  +    for country, langs in regions_json['locales'].items():
  +        for lang in langs['langs']:
  +            lang_code = "{lang}-{country}".format(lang=lang, country=country)
  +            supported_languages.append(lang_code)
   
       return supported_languages
  
verification_info: {"golden_diff": "diff --git a/searx/engines/qwant.py b/searx/engines/qwant.py\n--- a/searx/engines/qwant.py\n+++ b/searx/engines/qwant.py\n@@ -23,7 +23,7 @@\n # engine dependent config\n categories = []\n paging = True\n-supported_languages_url = 'https://qwant.com/region'\n+supported_languages_url = about['website']\n \n category_to_keyword = {'general': 'web',\n                        'images': 'images',\n@@ -125,15 +125,15 @@\n def _fetch_supported_languages(resp):\n     # list of regions is embedded in page as a js object\n     response_text = resp.text\n-    response_text = response_text[response_text.find('regionalisation'):]\n-    response_text = response_text[response_text.find('{'):response_text.find(');')]\n+    response_text = response_text[response_text.find('INITIAL_PROPS'):]\n+    response_text = response_text[response_text.find('{'):response_text.find('</script>')]\n \n     regions_json = loads(response_text)\n \n-    supported_languages = {}\n-    for lang in regions_json['languages'].values():\n-        for country in lang['countries']:\n-            lang_code = \"{lang}-{country}\".format(lang=lang['code'], country=country)\n-            supported_languages[lang_code] = {'name': lang['name']}\n+    supported_languages = []\n+    for country, langs in regions_json['locales'].items():\n+        for lang in langs['langs']:\n+            lang_code = \"{lang}-{country}\".format(lang=lang, country=country)\n+            supported_languages.append(lang_code)\n \n     return supported_languages\n", "issue": "Updating languages of qwant is broken\nThe URL used for retrieving available languages has gone:\r\n\r\n```\r\n    engines_languages = fetch_supported_languages()\r\n  File \"/home/runner/work/searx/searx/./searx_extra/update/update_languages.py\", line 30, in fetch_supported_languages\r\n    engines_languages[engine_name] = engines[engine_name].fetch_supported_languages()\r\n  File \"/home/runner/work/searx/searx/searx/engines/__init__.py\", line 141, in <lambda>\r\n    lambda: engine._fetch_supported_languages(get(engine.supported_languages_url, headers=headers)))\r\n  File \"/home/runner/work/searx/searx/searx/poolrequests.py\", line 209, in get\r\n    return request('get', url, **kwargs)\r\n  File \"/home/runner/work/searx/searx/searx/poolrequests.py\", line 202, in request\r\n    raise_for_httperror(response)\r\n  File \"/home/runner/work/searx/searx/searx/raise_for_httperror.py\", line 66, in raise_for_httperror\r\n    resp.raise_for_status()\r\n  File \"/home/runner/work/searx/searx/local/py3/lib/python3.9/site-packages/requests/models.py\", line 943, in raise_for_status\r\n    raise HTTPError(http_error_msg, response=self)\r\nrequests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://www.qwant.com/region\r\n```\r\n\r\nFull run: https://github.com/searx/searx/runs/2487497774?check_suite_focus=true\r\n\r\n@MarcAbonce If you have time could you please look into it? Or at least give some pointers how it can be fixed?\n", "before_files": [{"content": "# SPDX-License-Identifier: AGPL-3.0-or-later\n\"\"\"\n Qwant (Web, Images, News, Social)\n\"\"\"\n\nfrom datetime import datetime\nfrom json import loads\nfrom urllib.parse import urlencode\nfrom searx.utils import html_to_text, match_language\nfrom searx.exceptions import SearxEngineAPIException, SearxEngineCaptchaException\nfrom searx.raise_for_httperror import raise_for_httperror\n\n# about\nabout = {\n    \"website\": 'https://www.qwant.com/',\n    \"wikidata_id\": 'Q14657870',\n    \"official_api_documentation\": None,\n    \"use_official_api\": True,\n    \"require_api_key\": False,\n    \"results\": 'JSON',\n}\n\n# engine dependent config\ncategories = []\npaging = True\nsupported_languages_url = 'https://qwant.com/region'\n\ncategory_to_keyword = {'general': 'web',\n                       'images': 'images',\n                       'news': 'news'}\n\n# search-url\nurl = 'https://api.qwant.com/api/search/{keyword}?count=10&offset={offset}&f=&{query}&t={keyword}&uiv=4'\n\n\n# do search-request\ndef request(query, params):\n    offset = (params['pageno'] - 1) * 10\n\n    if categories[0] and categories[0] in category_to_keyword:\n\n        params['url'] = url.format(keyword=category_to_keyword[categories[0]],\n                                   query=urlencode({'q': query}),\n                                   offset=offset)\n    else:\n        params['url'] = url.format(keyword='web',\n                                   query=urlencode({'q': query}),\n                                   offset=offset)\n\n    # add language tag\n    if params['language'] != 'all':\n        language = match_language(params['language'], supported_languages, language_aliases)\n        params['url'] += '&locale=' + language.replace('-', '_').lower()\n\n    params['headers']['User-Agent'] = 'Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0'\n    params['raise_for_httperror'] = False\n    return params\n\n\n# get response from search-request\ndef response(resp):\n    results = []\n\n    # According to https://www.qwant.com/js/app.js\n    if resp.status_code == 429:\n        raise SearxEngineCaptchaException()\n\n    # raise for other errors\n    raise_for_httperror(resp)\n\n    # load JSON result\n    search_results = loads(resp.text)\n\n    # check for an API error\n    if search_results.get('status') != 'success':\n        raise SearxEngineAPIException('API error ' + str(search_results.get('error', '')))\n\n    # return empty array if there are no results\n    if 'data' not in search_results:\n        return []\n\n    data = search_results.get('data', {})\n\n    res = data.get('result', {})\n\n    # parse results\n    for result in res.get('items', {}):\n\n        title = html_to_text(result['title'])\n        res_url = result['url']\n        content = html_to_text(result['desc'])\n\n        if category_to_keyword.get(categories[0], '') == 'web':\n            results.append({'title': title,\n                            'content': content,\n                            'url': res_url})\n\n        elif category_to_keyword.get(categories[0], '') == 'images':\n            thumbnail_src = result['thumbnail']\n            img_src = result['media']\n            results.append({'template': 'images.html',\n                            'url': res_url,\n                            'title': title,\n                            'content': '',\n                            'thumbnail_src': thumbnail_src,\n                            'img_src': img_src})\n\n        elif category_to_keyword.get(categories[0], '') == 'news':\n            published_date = datetime.fromtimestamp(result['date'], None)\n            media = result.get('media', [])\n            if len(media) > 0:\n                img_src = media[0].get('pict', {}).get('url', None)\n            else:\n                img_src = None\n            results.append({'url': res_url,\n                            'title': title,\n                            'publishedDate': published_date,\n                            'content': content,\n                            'img_src': img_src})\n\n    return results\n\n\n# get supported languages from their site\ndef _fetch_supported_languages(resp):\n    # list of regions is embedded in page as a js object\n    response_text = resp.text\n    response_text = response_text[response_text.find('regionalisation'):]\n    response_text = response_text[response_text.find('{'):response_text.find(');')]\n\n    regions_json = loads(response_text)\n\n    supported_languages = {}\n    for lang in regions_json['languages'].values():\n        for country in lang['countries']:\n            lang_code = \"{lang}-{country}\".format(lang=lang['code'], country=country)\n            supported_languages[lang_code] = {'name': lang['name']}\n\n    return supported_languages\n", "path": "searx/engines/qwant.py"}], "after_files": [{"content": "# SPDX-License-Identifier: AGPL-3.0-or-later\n\"\"\"\n Qwant (Web, Images, News, Social)\n\"\"\"\n\nfrom datetime import datetime\nfrom json import loads\nfrom urllib.parse import urlencode\nfrom searx.utils import html_to_text, match_language\nfrom searx.exceptions import SearxEngineAPIException, SearxEngineCaptchaException\nfrom searx.raise_for_httperror import raise_for_httperror\n\n# about\nabout = {\n    \"website\": 'https://www.qwant.com/',\n    \"wikidata_id\": 'Q14657870',\n    \"official_api_documentation\": None,\n    \"use_official_api\": True,\n    \"require_api_key\": False,\n    \"results\": 'JSON',\n}\n\n# engine dependent config\ncategories = []\npaging = True\nsupported_languages_url = about['website']\n\ncategory_to_keyword = {'general': 'web',\n                       'images': 'images',\n                       'news': 'news'}\n\n# search-url\nurl = 'https://api.qwant.com/api/search/{keyword}?count=10&offset={offset}&f=&{query}&t={keyword}&uiv=4'\n\n\n# do search-request\ndef request(query, params):\n    offset = (params['pageno'] - 1) * 10\n\n    if categories[0] and categories[0] in category_to_keyword:\n\n        params['url'] = url.format(keyword=category_to_keyword[categories[0]],\n                                   query=urlencode({'q': query}),\n                                   offset=offset)\n    else:\n        params['url'] = url.format(keyword='web',\n                                   query=urlencode({'q': query}),\n                                   offset=offset)\n\n    # add language tag\n    if params['language'] != 'all':\n        language = match_language(params['language'], supported_languages, language_aliases)\n        params['url'] += '&locale=' + language.replace('-', '_').lower()\n\n    params['headers']['User-Agent'] = 'Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0'\n    params['raise_for_httperror'] = False\n    return params\n\n\n# get response from search-request\ndef response(resp):\n    results = []\n\n    # According to https://www.qwant.com/js/app.js\n    if resp.status_code == 429:\n        raise SearxEngineCaptchaException()\n\n    # raise for other errors\n    raise_for_httperror(resp)\n\n    # load JSON result\n    search_results = loads(resp.text)\n\n    # check for an API error\n    if search_results.get('status') != 'success':\n        raise SearxEngineAPIException('API error ' + str(search_results.get('error', '')))\n\n    # return empty array if there are no results\n    if 'data' not in search_results:\n        return []\n\n    data = search_results.get('data', {})\n\n    res = data.get('result', {})\n\n    # parse results\n    for result in res.get('items', {}):\n\n        title = html_to_text(result['title'])\n        res_url = result['url']\n        content = html_to_text(result['desc'])\n\n        if category_to_keyword.get(categories[0], '') == 'web':\n            results.append({'title': title,\n                            'content': content,\n                            'url': res_url})\n\n        elif category_to_keyword.get(categories[0], '') == 'images':\n            thumbnail_src = result['thumbnail']\n            img_src = result['media']\n            results.append({'template': 'images.html',\n                            'url': res_url,\n                            'title': title,\n                            'content': '',\n                            'thumbnail_src': thumbnail_src,\n                            'img_src': img_src})\n\n        elif category_to_keyword.get(categories[0], '') == 'news':\n            published_date = datetime.fromtimestamp(result['date'], None)\n            media = result.get('media', [])\n            if len(media) > 0:\n                img_src = media[0].get('pict', {}).get('url', None)\n            else:\n                img_src = None\n            results.append({'url': res_url,\n                            'title': title,\n                            'publishedDate': published_date,\n                            'content': content,\n                            'img_src': img_src})\n\n    return results\n\n\n# get supported languages from their site\ndef _fetch_supported_languages(resp):\n    # list of regions is embedded in page as a js object\n    response_text = resp.text\n    response_text = response_text[response_text.find('INITIAL_PROPS'):]\n    response_text = response_text[response_text.find('{'):response_text.find('</script>')]\n\n    regions_json = loads(response_text)\n\n    supported_languages = []\n    for country, langs in regions_json['locales'].items():\n        for lang in langs['langs']:\n            lang_code = \"{lang}-{country}\".format(lang=lang, country=country)\n            supported_languages.append(lang_code)\n\n    return supported_languages\n", "path": "searx/engines/qwant.py"}]}