diff options
| author | Austin-Olacsi <138650713+Austin-Olacsi@users.noreply.github.com> | 2025-11-22 01:59:38 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-22 09:59:38 +0100 |
| commit | c852b9a90a29db386bceb283a8b01e0952876ec6 (patch) | |
| tree | bc36dc4e06093e4d3ee46a610ed0556fbad3b6b1 /searx/engines | |
| parent | b876d0bed01422687f3f044658cab0afa9e0e19f (diff) | |
[feat] engine: add grokipedia (#5396)
Diffstat (limited to 'searx/engines')
| -rw-r--r-- | searx/engines/grokipedia.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/searx/engines/grokipedia.py b/searx/engines/grokipedia.py new file mode 100644 index 000000000..d0ce60902 --- /dev/null +++ b/searx/engines/grokipedia.py @@ -0,0 +1,52 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +"""Grokipedia (general)""" + +from urllib.parse import urlencode +from searx.utils import html_to_text +from searx.result_types import EngineResults + +about = { + "website": 'https://grokipedia.com', + "wikidata_id": "Q136410803", + "official_api_documentation": None, + "use_official_api": False, + "require_api_key": False, + "results": "JSON", +} + +base_url = "https://grokipedia.com/api/full-text-search" +categories = ['general'] +paging = True +results_per_page = 10 + + +def request(query, params): + + start_index = (params["pageno"] - 1) * results_per_page + + query_params = { + "query": query, + "limit": results_per_page, + "offset": start_index, + } + + params["url"] = f"{base_url}?{urlencode(query_params)}" + + return params + + +def response(resp) -> EngineResults: + results = EngineResults() + search_res = resp.json() + + for item in search_res["results"]: + + results.add( + results.types.MainResult( + url='https://grokipedia.com/page/' + item["slug"], + title=item["title"], + content=html_to_text(item["snippet"]), + ) + ) + + return results |