[feat] new engine: wikispecies

This commit is contained in:
Bnyro 2023-08-03 19:07:22 +02:00 committed by Markus Heiser
parent 5a5b95df3e
commit 7d8c20c80d
2 changed files with 16 additions and 3 deletions

View File

@ -3,10 +3,11 @@
General mediawiki-engine (Web) General mediawiki-engine (Web)
""" """
from json import loads
from string import Formatter from string import Formatter
from urllib.parse import urlencode, quote from urllib.parse import urlencode, quote
from searx.utils import html_to_text
# about # about
about = { about = {
"website": None, "website": None,
@ -69,7 +70,7 @@ def request(query, params):
def response(resp): def response(resp):
results = [] results = []
search_results = loads(resp.text) search_results = resp.json()
# return empty array if there are no results # return empty array if there are no results
if not search_results.get('query', {}).get('search'): if not search_results.get('query', {}).get('search'):
@ -86,7 +87,7 @@ def response(resp):
) )
# append result # append result
results.append({'url': url, 'title': result['title'], 'content': ''}) results.append({'url': url, 'title': result['title'], 'content': html_to_text(result.get('snippet', ''))})
# return results # return results
return results return results

View File

@ -1579,6 +1579,18 @@ engines:
website: https://www.wikisource.org/ website: https://www.wikisource.org/
wikidata_id: Q263 wikidata_id: Q263
- name: wikipecies
engine: mediawiki
shortcut: wsp
categories: [general, science]
base_url: "https://species.wikimedia.org/"
number_of_results: 5
search_type: text
disabled: true
about:
website: https://species.wikimedia.org/
wikidata_id: Q13679
- name: wiktionary - name: wiktionary
engine: mediawiki engine: mediawiki
shortcut: wt shortcut: wt