mirror of
https://github.com/searxng/searxng.git
synced 2025-07-23 13:19:17 +02:00
[feat] add Sogou engine for searxng
Co-authored-by: Bnyro <bnyro@tutanota.com>
This commit is contained in:
parent
71d1504e57
commit
97aa5a779b
6 changed files with 225 additions and 1 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue