diff options
| author | Zhijie He <hezhijie0327@hotmail.com> | 2025-05-22 00:25:02 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-21 18:25:02 +0200 |
| commit | 156d1eb8c85c01c94723188859fa7526c7d72698 (patch) | |
| tree | 7a8f627d62580103e504aaf8ac8ec47c132bbdf0 /searx/autocomplete.py | |
| parent | 365b9426f17d3372647c89307ad7175f862834e8 (diff) | |
[feat] engines: add Naver engine (#4573)
Refactor Naver engine (Web, News, Images, Videos, Autocomplete)
- ref: https://search.naver.com/
- lang: `ko`
- Wikidata: https://www.wikidata.org/wiki/Q485639
Co-authored-by: Bnyro <bnyro@tutanota.com>
Diffstat (limited to 'searx/autocomplete.py')
| -rw-r--r-- | searx/autocomplete.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/searx/autocomplete.py b/searx/autocomplete.py index ebe6972e3..05a641829 100644 --- a/searx/autocomplete.py +++ b/searx/autocomplete.py @@ -149,6 +149,21 @@ def mwmbl(query, _lang): return [result for result in results if not result.startswith("go: ") and not result.startswith("search: ")] +def naver(query, _lang): + # Naver search autocompleter + url = f"https://ac.search.naver.com/nx/ac?{urlencode({'q': query, 'r_format': 'json', 'st': 0})}" + response = get(url) + + results = [] + + if response.ok: + data = response.json() + if data.get('items'): + for item in data['items'][0]: + results.append(item[0]) + return results + + def qihu360search(query, _lang): # 360Search search autocompleter url = f"https://sug.so.360.cn/suggest?{urlencode({'format': 'json', 'word': query})}" @@ -300,6 +315,7 @@ backends = { 'duckduckgo': duckduckgo, 'google': google_complete, 'mwmbl': mwmbl, + 'naver': naver, 'quark': quark, 'qwant': qwant, 'seznam': seznam, |