mirror of
https://github.com/searxng/searxng.git
synced 2026-08-12 02:01:36 +00:00
Compare commits
9 Commits
99ad69450d
...
777ba6ddf8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
777ba6ddf8 | ||
|
|
8ca57748ff | ||
|
|
30399c50e2 | ||
|
|
e6467bce7c | ||
|
|
8ca2bbc4e9 | ||
|
|
a74593419f | ||
|
|
f94802f2d2 | ||
|
|
d1c584b961 | ||
|
|
81f3d15665 |
@@ -96,7 +96,7 @@ Modify the ``/etc/searxng/settings.yml`` to your needs:
|
|||||||
|
|
||||||
.. literalinclude:: ../../utils/templates/etc/searxng/settings.yml
|
.. literalinclude:: ../../utils/templates/etc/searxng/settings.yml
|
||||||
:language: yaml
|
:language: yaml
|
||||||
:end-before: # hostnames:
|
:end-before: # preferences:
|
||||||
|
|
||||||
To see the entire file jump to :origin:`utils/templates/etc/searxng/settings.yml`
|
To see the entire file jump to :origin:`utils/templates/etc/searxng/settings.yml`
|
||||||
|
|
||||||
|
|||||||
@@ -27,23 +27,24 @@ Privacy-by-design
|
|||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
SearXNG was born out of the need for a **privacy-respecting** search tool which
|
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.
|
capabilities.
|
||||||
|
|
||||||
A few widely used features work differently or turned off by default or not
|
Some widely used search engine features may work differently,
|
||||||
implemented at all **as a consequence of privacy-by-design**.
|
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
|
Following this approach, features reducing the privacy preserving aspects of SearXNG should be
|
||||||
switched off by default or should not implemented at all. There are plenty of
|
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 the
|
search engines already providing such features. If a feature reduces
|
||||||
protection of searx, users must be informed about the effect of choosing to
|
SearXNG's efficacy in protecting a user's privacy, the user must be informed about
|
||||||
enable it. Features that protect privacy but differ from the expectations of
|
the effect of choosing to enable it. Features that protect privacy but differ from the
|
||||||
the user should also be explained.
|
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
|
Also, if you think that something works weird with SearXNG, it might be because
|
||||||
of the tool you use is designed in a way to interfere with the privacy respect.
|
the tool you are using is designed in a way that interferes with SearXNG's privacy aspects.
|
||||||
Submitting a bugreport to the vendor of the tool that misbehaves might be a good
|
Submitting a bug report 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``
|
feedback for them to reconsider the disrespect to their customers (e.g., ``GET`` vs ``POST``
|
||||||
requests in various browsers).
|
requests in various browsers).
|
||||||
|
|
||||||
Remember the other prime directive of SearXNG is to be hackable, so if the above
|
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:
|
.. _make docs.live:
|
||||||
|
|
||||||
live build
|
Live build
|
||||||
----------
|
----------
|
||||||
|
|
||||||
.. _sphinx-autobuild:
|
.. _sphinx-autobuild:
|
||||||
@@ -145,8 +146,8 @@ live build
|
|||||||
It is recommended to assert a complete rebuild before deploying (use
|
It is recommended to assert a complete rebuild before deploying (use
|
||||||
``docs.clean``).
|
``docs.clean``).
|
||||||
|
|
||||||
Live build is like WYSIWYG. If you want to edit the documentation, its
|
Live build is like WYSIWYG. It's the recommended way to go if you want to edit the documentation.
|
||||||
recommended to use. The Makefile target ``docs.live`` builds the docs, opens
|
The Makefile target ``docs.live`` builds the docs, opens
|
||||||
URL in your favorite browser and rebuilds every time a reST file has been
|
URL in your favorite browser and rebuilds every time a reST file has been
|
||||||
changed (:ref:`make docs.clean`).
|
changed (:ref:`make docs.clean`).
|
||||||
|
|
||||||
@@ -159,9 +160,9 @@ changed (:ref:`make docs.clean`).
|
|||||||
... Start watching changes
|
... Start watching changes
|
||||||
|
|
||||||
Live builds are implemented by sphinx-autobuild_. Use environment
|
Live builds are implemented by sphinx-autobuild_. Use environment
|
||||||
``$(SPHINXOPTS)`` to pass arguments to the sphinx-autobuild_ command. Except
|
``$(SPHINXOPTS)`` to pass arguments to the sphinx-autobuild_ command. You can
|
||||||
option ``--host`` (which is always set to ``0.0.0.0``) you can pass any
|
pass any argument except for the ``--host`` option (which is always set to ``0.0.0.0``).
|
||||||
argument. E.g to find and use a free port, use:
|
E.g., to find and use a free port, use:
|
||||||
|
|
||||||
.. code:: sh
|
.. code:: sh
|
||||||
|
|
||||||
|
|||||||
8
docs/dev/engines/online/huggingface.rst
Normal file
8
docs/dev/engines/online/huggingface.rst
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
.. _huggingface engine:
|
||||||
|
|
||||||
|
============
|
||||||
|
Hugging Face
|
||||||
|
============
|
||||||
|
|
||||||
|
.. automodule:: searx.engines.huggingface
|
||||||
|
:members:
|
||||||
@@ -6,7 +6,7 @@ Simple Theme Templates
|
|||||||
|
|
||||||
The simple template is complex, it consists of many different elements and also
|
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
|
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/>`.
|
:origin:`sources <searx/templates/simple/>`.
|
||||||
|
|
||||||
A :ref:`result item <result types>` can be of different media types. The media
|
A :ref:`result item <result types>` can be of different media types. The media
|
||||||
|
|||||||
81
searx/engines/ansa.py
Normal file
81
searx/engines/ansa.py
Normal 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
|
||||||
116
searx/engines/huggingface.py
Normal file
116
searx/engines/huggingface.py
Normal 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
|
||||||
@@ -83,7 +83,7 @@ server:
|
|||||||
port: 8888
|
port: 8888
|
||||||
bind_address: "127.0.0.1"
|
bind_address: "127.0.0.1"
|
||||||
# public URL of the instance, to ensure correct inbound links. Is overwritten
|
# 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"
|
base_url: false # "http://example.com/location"
|
||||||
# rate limit the number of request on the instance, block some bots.
|
# rate limit the number of request on the instance, block some bots.
|
||||||
# Is overwritten by ${SEARXNG_LIMITER}
|
# Is overwritten by ${SEARXNG_LIMITER}
|
||||||
@@ -433,6 +433,11 @@ engines:
|
|||||||
disabled: true
|
disabled: true
|
||||||
shortcut: aa
|
shortcut: aa
|
||||||
|
|
||||||
|
- name: ansa
|
||||||
|
engine: ansa
|
||||||
|
shortcut: ans
|
||||||
|
disabled: true
|
||||||
|
|
||||||
# - name: annas articles
|
# - name: annas articles
|
||||||
# engine: annas_archive
|
# engine: annas_archive
|
||||||
# shortcut: aaa
|
# shortcut: aaa
|
||||||
@@ -1129,6 +1134,22 @@ engines:
|
|||||||
- name: il post
|
- name: il post
|
||||||
engine: il_post
|
engine: il_post
|
||||||
shortcut: pst
|
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
|
disabled: true
|
||||||
|
|
||||||
- name: imdb
|
- name: imdb
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ general:
|
|||||||
search:
|
search:
|
||||||
safe_search: 2
|
safe_search: 2
|
||||||
autocomplete: 'duckduckgo'
|
autocomplete: 'duckduckgo'
|
||||||
|
formats:
|
||||||
|
- html
|
||||||
|
|
||||||
server:
|
server:
|
||||||
# Is overwritten by ${SEARXNG_SECRET}
|
# Is overwritten by ${SEARXNG_SECRET}
|
||||||
@@ -16,7 +18,7 @@ server:
|
|||||||
limiter: true
|
limiter: true
|
||||||
image_proxy: true
|
image_proxy: true
|
||||||
# public URL of the instance, to ensure correct inbound links. Is overwritten
|
# 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
|
# base_url: http://example.com/location
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
@@ -31,30 +33,8 @@ ui:
|
|||||||
# - autocomplete
|
# - autocomplete
|
||||||
# - method
|
# - method
|
||||||
|
|
||||||
enabled_plugins:
|
# engines:
|
||||||
- '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:
|
|
||||||
|
|
||||||
# - name: fdroid
|
# - name: fdroid
|
||||||
# disabled: false
|
# disabled: false
|
||||||
#
|
#
|
||||||
@@ -64,11 +44,3 @@ engines:
|
|||||||
# - name: mediathekviewweb
|
# - name: mediathekviewweb
|
||||||
# categories: TV
|
# categories: TV
|
||||||
# disabled: false
|
# disabled: false
|
||||||
#
|
|
||||||
# - name: invidious
|
|
||||||
# disabled: false
|
|
||||||
# base_url:
|
|
||||||
# - https://invidious.snopyta.org
|
|
||||||
# - https://invidious.tiekoetter.com
|
|
||||||
# - https://invidio.xamh.de
|
|
||||||
# - https://inv.riverside.rocks
|
|
||||||
|
|||||||
Reference in New Issue
Block a user