diff options
| author | Zhijie He <hezhijie0327@hotmail.com> | 2025-02-23 13:47:03 +0800 |
|---|---|---|
| committer | Bnyro <bnyro@tutanota.com> | 2025-03-02 13:31:31 +0100 |
| commit | 97aa5a779b3910efb2cc8f7497969fbe0d126910 (patch) | |
| tree | 2ece13de46369a42d7441ec531ebabaae97ac919 /searx/autocomplete.py | |
| parent | 71d1504e572074327f851688a4caac90a5e41fe8 (diff) | |
[feat] add Sogou engine for searxng
Co-authored-by: Bnyro <bnyro@tutanota.com>
Diffstat (limited to 'searx/autocomplete.py')
| -rw-r--r-- | searx/autocomplete.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/searx/autocomplete.py b/searx/autocomplete.py index 2ef6189a5..8a4f0a66a 100644 --- a/searx/autocomplete.py +++ b/searx/autocomplete.py @@ -20,6 +20,7 @@ from searx.engines import ( ) from searx.network import get as http_get, post as http_post from searx.exceptions import SearxEngineResponseException +from searx.utils import extr def update_kwargs(**kwargs): @@ -186,6 +187,23 @@ def seznam(query, _lang): ] +def sogou(query, _lang): + # Sogou search autocompleter + base_url = "https://sor.html5.qq.com/api/getsug?" + response = get(base_url + urlencode({'m': 'searxng', 'key': query})) + + if response.ok: + raw_json = extr(response.text, "[", "]", default="") + + try: + data = json.loads(f"[{raw_json}]]") + return data[1] + except json.JSONDecodeError: + return [] + + return [] + + def stract(query, _lang): # stract autocompleter (beta) url = f"https://stract.com/beta/api/autosuggest?q={quote_plus(query)}" @@ -270,6 +288,7 @@ backends = { 'mwmbl': mwmbl, 'qwant': qwant, 'seznam': seznam, + 'sogou': sogou, 'stract': stract, 'swisscows': swisscows, 'wikipedia': wikipedia, |