9 Commits

Author SHA1 Message Date
Markus Heiser
777ba6ddf8 [fix] disable engine ansa by default
Reported-by: https://github.com/searxng/searxng/pull/4575#issuecomment-2813007107
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2025-04-17 16:50:57 +02:00
Tommaso Colella
8ca57748ff [fix] docs: changed "many" to "some" for clarity in contribution guide's privacy by design section 2025-04-17 16:47:52 +02:00
Tommaso Colella
30399c50e2 [fix] docs: typos and minor refinements in contribution_guide.rst 2025-04-17 16:47:52 +02:00
Tommaso Colella
e6467bce7c [fix] docs: better phrasing for many sections of contribution_guide.rst 2025-04-17 16:47:52 +02:00
Tommaso Colella
8ca2bbc4e9 [fix] docs: typos in dev contrib guide "it's might be because
of the tool" -> "it might be because the tool"
2025-04-17 16:47:52 +02:00
Tommaso Colella
a74593419f [fix] docs: typo in templates dev doc developerat -> developer at 2025-04-17 16:47:52 +02:00
Zhijie He
f94802f2d2 [feat] engines: add Hugging Face engine 2025-04-17 16:43:32 +02:00
Tommaso Colella
d1c584b961 [feat] engine: add engine for italian press agency ansa 2025-04-17 15:33:57 +02:00
Markus Heiser
81f3d15665 [fix] settings.yml files: doc & obsolete settings in the template
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2025-04-17 13:31:10 +02:00
8 changed files with 254 additions and 55 deletions

View File

@@ -96,7 +96,7 @@ Modify the ``/etc/searxng/settings.yml`` to your needs:
.. literalinclude:: ../../utils/templates/etc/searxng/settings.yml
:language: yaml
:end-before: # hostnames:
:end-before: # preferences:
To see the entire file jump to :origin:`utils/templates/etc/searxng/settings.yml`

View File

@@ -27,23 +27,24 @@ Privacy-by-design
-----------------
SearXNG was born out of the need for a **privacy-respecting** search tool which
can be extended easily to maximize both, its search and its privacy protecting
can be extended easily to maximize both its search and its privacy protecting
capabilities.
A few widely used features work differently or turned off by default or not
implemented at all **as a consequence of privacy-by-design**.
Some widely used search engine features may work differently,
may be turned off by default, or may not be implemented at all in SearXNG
**as a consequence of a privacy-by-design approach**.
If a feature reduces the privacy preserving aspects of searx, it should be
switched off by default or should not implemented at all. There are plenty of
search engines already providing such features. If a feature reduces the
protection of searx, users must be informed about the effect of choosing to
enable it. Features that protect privacy but differ from the expectations of
the user should also be explained.
Following this approach, features reducing the privacy preserving aspects of SearXNG should be
switched off by default or should not be implemented at all. There are plenty of
search engines already providing such features. If a feature reduces
SearXNG's efficacy in protecting a user's privacy, the user must be informed about
the effect of choosing to enable it. Features that protect privacy but differ from the
expectations of the user should also be carefully explained to them.
Also, if you think that something works weird with searx, it's might be because
of the tool you use is designed in a way to interfere with the privacy respect.
Submitting a bugreport to the vendor of the tool that misbehaves might be a good
feedback to reconsider the disrespect to its customers (e.g. ``GET`` vs ``POST``
Also, if you think that something works weird with SearXNG, it might be because
the tool you are using is designed in a way that interferes with SearXNG's privacy aspects.
Submitting a bug report to the vendor of the tool that misbehaves might be a good
feedback for them to reconsider the disrespect to their customers (e.g., ``GET`` vs ``POST``
requests in various browsers).
Remember the other prime directive of SearXNG is to be hackable, so if the above
@@ -134,7 +135,7 @@ Here is an example which makes a complete rebuild:
.. _make docs.live:
live build
Live build
----------
.. _sphinx-autobuild:
@@ -145,8 +146,8 @@ live build
It is recommended to assert a complete rebuild before deploying (use
``docs.clean``).
Live build is like WYSIWYG. If you want to edit the documentation, its
recommended to use. The Makefile target ``docs.live`` builds the docs, opens
Live build is like WYSIWYG. It's the recommended way to go if you want to edit the documentation.
The Makefile target ``docs.live`` builds the docs, opens
URL in your favorite browser and rebuilds every time a reST file has been
changed (:ref:`make docs.clean`).
@@ -159,9 +160,9 @@ changed (:ref:`make docs.clean`).
... Start watching changes
Live builds are implemented by sphinx-autobuild_. Use environment
``$(SPHINXOPTS)`` to pass arguments to the sphinx-autobuild_ command. Except
option ``--host`` (which is always set to ``0.0.0.0``) you can pass any
argument. E.g to find and use a free port, use:
``$(SPHINXOPTS)`` to pass arguments to the sphinx-autobuild_ command. You can
pass any argument except for the ``--host`` option (which is always set to ``0.0.0.0``).
E.g., to find and use a free port, use:
.. code:: sh

View File

@@ -0,0 +1,8 @@
.. _huggingface engine:
============
Hugging Face
============
.. automodule:: searx.engines.huggingface
:members:

View File

@@ -6,7 +6,7 @@ Simple Theme Templates
The simple template is complex, it consists of many different elements and also
uses macros and include statements. The following is a rough overview that we
would like to give the developerat hand, details must still be taken from the
would like to give the developer at hand, details must still be taken from the
:origin:`sources <searx/templates/simple/>`.
A :ref:`result item <result types>` can be of different media types. The media

81
searx/engines/ansa.py Normal file
View File

@@ -0,0 +1,81 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""Engine for Ansa, Italy's oldest news agency.
To use this engine add the following entry to your engines
list in ``settings.yml``:
.. code:: yaml
- name: ansa
engine: ansa
shortcut: ans
disabled: false
"""
from urllib.parse import urlencode
from lxml import html
from searx.result_types import EngineResults, MainResult
from searx.utils import eval_xpath, eval_xpath_list, extract_text
engine_type = 'online'
language_support = False
categories = ['news']
paging = True
page_size = 12
base_url = 'https://www.ansa.it'
time_range_support = True
time_range_args = {
'day': 1,
'week': 7,
'month': 31,
'year': 365,
}
# https://www.ansa.it/ricerca/ansait/search.shtml?start=0&any=houthi&periodo=&sort=data%3Adesc
search_api = 'https://www.ansa.it/ricerca/ansait/search.shtml?'
about = {
'website': 'https://www.ansa.it',
'wikidata_id': 'Q392934',
'official_api_documentation': None,
'use_official_api': False,
'require_api_key': False,
'results': 'HTML',
'language': 'it',
}
def request(query, params):
query_params = {
'any': query,
'start': (params['pageno'] - 1) * page_size,
'sort': "data:desc",
}
if params['time_range']:
query_params['periodo'] = time_range_args.get(params['time_range'])
params['url'] = search_api + urlencode(query_params)
return params
def response(resp) -> EngineResults:
res = EngineResults()
doc = html.fromstring(resp.text)
for result in eval_xpath_list(doc, "//div[@class='article']"):
res_obj = MainResult(
title=extract_text(eval_xpath(result, "./div[@class='content']/h2[@class='title']/a")),
content=extract_text(eval_xpath(result, "./div[@class='content']/div[@class='text']")),
url=base_url + extract_text(eval_xpath(result, "./div[@class='content']/h2[@class='title']/a/@href")),
)
thumbnail = extract_text(eval_xpath(result, "./div[@class='image']/a/img/@src"))
if thumbnail:
res_obj.thumbnail = base_url + thumbnail
res.append(res_obj)
return res

View File

@@ -0,0 +1,116 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""`Hugging Face`_ search engine for SearXNG.
.. _Hugging Face: https://huggingface.co
Configuration
=============
The engine has the following additional settings:
- :py:obj:`huggingface_endpoint`
Configurations for endpoints:
.. code:: yaml
- name: huggingface
engine: huggingface
shortcut: hf
- name: huggingface datasets
huggingface_endpoint: datasets
engine: huggingface
shortcut: hfd
- name: huggingface spaces
huggingface_endpoint: spaces
engine: huggingface
shortcut: hfs
Implementations
===============
"""
from urllib.parse import urlencode
from datetime import datetime
from searx.exceptions import SearxEngineAPIException
from searx.utils import html_to_text
from searx.result_types import EngineResults, MainResult
about = {
"website": "https://huggingface.co/",
"wikidata_id": "Q108943604",
"official_api_documentation": "https://huggingface.co/docs/hub/en/api",
"use_official_api": True,
"require_api_key": False,
"results": "JSON",
}
categories = ['it', 'repos']
base_url = "https://huggingface.co"
huggingface_endpoint = 'models'
"""Hugging Face supports datasets, models, spaces as search endpoint.
- ``datasets``: search for datasets
- ``models``: search for models
- ``spaces``: search for spaces
"""
def init(_):
if huggingface_endpoint not in ('datasets', 'models', 'spaces'):
raise SearxEngineAPIException(f"Unsupported Hugging Face endpoint: {huggingface_endpoint}")
def request(query, params):
query_params = {
"direction": -1,
"search": query,
}
params["url"] = f"{base_url}/api/{huggingface_endpoint}?{urlencode(query_params)}"
return params
def response(resp) -> EngineResults:
results = EngineResults()
data = resp.json()
for entry in data:
if huggingface_endpoint != 'models':
url = f"{base_url}/{huggingface_endpoint}/{entry['id']}"
else:
url = f"{base_url}/{entry['id']}"
published_date = None
try:
published_date = datetime.strptime(entry["createdAt"], "%Y-%m-%dT%H:%M:%S.%fZ")
except (ValueError, TypeError):
pass
contents = []
if entry.get("likes"):
contents.append(f"Likes: {entry['likes']}")
if entry.get("downloads"):
contents.append(f"Downloads: {entry['downloads']:,}")
if entry.get("tags"):
contents.append(f"Tags: {', '.join(entry['tags'])}")
if entry.get("description"):
contents.append(f"Description: {entry['description']}")
item = MainResult(
title=entry["id"],
content=html_to_text(" | ".join(contents)),
url=url,
publishedDate=published_date,
)
results.add(item)
return results

View File

@@ -83,7 +83,7 @@ server:
port: 8888
bind_address: "127.0.0.1"
# public URL of the instance, to ensure correct inbound links. Is overwritten
# by ${SEARXNG_URL}.
# by ${SEARXNG_BASE_URL}.
base_url: false # "http://example.com/location"
# rate limit the number of request on the instance, block some bots.
# Is overwritten by ${SEARXNG_LIMITER}
@@ -433,6 +433,11 @@ engines:
disabled: true
shortcut: aa
- name: ansa
engine: ansa
shortcut: ans
disabled: true
# - name: annas articles
# engine: annas_archive
# shortcut: aaa
@@ -1129,6 +1134,22 @@ engines:
- name: il post
engine: il_post
shortcut: pst
- name: huggingface
engine: huggingface
shortcut: hf
disabled: true
- name: huggingface datasets
huggingface_endpoint: datasets
engine: huggingface
shortcut: hfd
disabled: true
- name: huggingface spaces
huggingface_endpoint: spaces
engine: huggingface
shortcut: hfs
disabled: true
- name: imdb

View File

@@ -9,6 +9,8 @@ general:
search:
safe_search: 2
autocomplete: 'duckduckgo'
formats:
- html
server:
# Is overwritten by ${SEARXNG_SECRET}
@@ -16,7 +18,7 @@ server:
limiter: true
image_proxy: true
# public URL of the instance, to ensure correct inbound links. Is overwritten
# by ${SEARXNG_URL}.
# by ${SEARXNG_BASE_URL}.
# base_url: http://example.com/location
redis:
@@ -31,30 +33,8 @@ ui:
# - autocomplete
# - method
enabled_plugins:
- 'Hash plugin'
- 'Self Information'
- 'Tracker URL remover'
- 'Ahmia blacklist'
# - 'Hostnames plugin' # see 'hostnames' configuration below
# - 'Open Access DOI rewrite'
# plugins:
# - only_show_green_results
# hostnames:
# replace:
# '(.*\.)?youtube\.com$': 'invidious.example.com'
# '(.*\.)?youtu\.be$': 'invidious.example.com'
# remove:
# - '(.*\.)?facebook.com$'
# low_priority:
# - '(.*\.)?google\.com$'
# high_priority:
# - '(.*\.)?wikipedia.org$'
engines:
# engines:
#
# - name: fdroid
# disabled: false
#
@@ -64,11 +44,3 @@ engines:
# - name: mediathekviewweb
# categories: TV
# disabled: false
#
# - name: invidious
# disabled: false
# base_url:
# - https://invidious.snopyta.org
# - https://invidious.tiekoetter.com
# - https://invidio.xamh.de
# - https://inv.riverside.rocks