mirror of https://github.com/searxng/searxng.git
252 lines
14 KiB
HTML
252 lines
14 KiB
HTML
<!DOCTYPE html>
|
|
|
|
<html lang="en" data-content_root="../../">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>searx.enginelib — SearXNG Documentation (2024.10.29+fa4dfd4ef)</title>
|
|
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=4f649999" />
|
|
<link rel="stylesheet" type="text/css" href="../../_static/searxng.css?v=52e4ff28" />
|
|
<link rel="stylesheet" type="text/css" href="../../_static/autodoc_pydantic.css" />
|
|
<script src="../../_static/documentation_options.js?v=605fe176"></script>
|
|
<script src="../../_static/doctools.js?v=9a2dae69"></script>
|
|
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
|
|
<script data-project="searxng" data-version="2024.10.29+fa4dfd4ef" src="../../_static/describe_version.js?v=fa7f30d0"></script>
|
|
<link rel="index" title="Index" href="../../genindex.html" />
|
|
<link rel="search" title="Search" href="../../search.html" />
|
|
</head><body>
|
|
<div class="related" role="navigation" aria-label="Related">
|
|
<h3>Navigation</h3>
|
|
<ul>
|
|
<li class="right" style="margin-right: 10px">
|
|
<a href="../../genindex.html" title="General Index"
|
|
accesskey="I">index</a></li>
|
|
<li class="right" >
|
|
<a href="../../py-modindex.html" title="Python Module Index"
|
|
>modules</a> |</li>
|
|
<li class="nav-item nav-item-0"><a href="../../index.html">SearXNG Documentation (2024.10.29+fa4dfd4ef)</a> »</li>
|
|
<li class="nav-item nav-item-1"><a href="../index.html" accesskey="U">Module code</a> »</li>
|
|
<li class="nav-item nav-item-this"><a href="">searx.enginelib</a></li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="document">
|
|
<div class="documentwrapper">
|
|
<div class="bodywrapper">
|
|
<div class="body" role="main">
|
|
|
|
<h1>Source code for searx.enginelib</h1><div class="highlight"><pre>
|
|
<span></span><span class="c1"># SPDX-License-Identifier: AGPL-3.0-or-later</span>
|
|
<span class="sd">"""Implementations of the framework for the SearXNG engines.</span>
|
|
|
|
<span class="sd">.. hint::</span>
|
|
|
|
<span class="sd"> The long term goal is to modularize all implementations of the engine</span>
|
|
<span class="sd"> framework here in this Python package. ToDo:</span>
|
|
|
|
<span class="sd"> - move implementations of the :ref:`searx.engines loader` to a new module in</span>
|
|
<span class="sd"> the :py:obj:`searx.enginelib` namespace.</span>
|
|
|
|
<span class="sd">"""</span>
|
|
|
|
|
|
<span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">annotations</span>
|
|
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">List</span><span class="p">,</span> <span class="n">Callable</span><span class="p">,</span> <span class="n">TYPE_CHECKING</span>
|
|
|
|
<span class="k">if</span> <span class="n">TYPE_CHECKING</span><span class="p">:</span>
|
|
<span class="kn">from</span> <span class="nn">searx.enginelib</span> <span class="kn">import</span> <span class="n">traits</span>
|
|
|
|
|
|
<div class="viewcode-block" id="Engine">
|
|
<a class="viewcode-back" href="../../dev/engines/enginelib.html#searx.enginelib.Engine">[docs]</a>
|
|
<span class="k">class</span> <span class="nc">Engine</span><span class="p">:</span> <span class="c1"># pylint: disable=too-few-public-methods</span>
|
|
<span class="w"> </span><span class="sd">"""Class of engine instances build from YAML settings.</span>
|
|
|
|
<span class="sd"> Further documentation see :ref:`general engine configuration`.</span>
|
|
|
|
<span class="sd"> .. hint::</span>
|
|
|
|
<span class="sd"> This class is currently never initialized and only used for type hinting.</span>
|
|
<span class="sd"> """</span>
|
|
|
|
<span class="c1"># Common options in the engine module</span>
|
|
|
|
<span class="n">engine_type</span><span class="p">:</span> <span class="nb">str</span>
|
|
<span class="w"> </span><span class="sd">"""Type of the engine (:ref:`searx.search.processors`)"""</span>
|
|
|
|
<span class="n">paging</span><span class="p">:</span> <span class="nb">bool</span>
|
|
<span class="w"> </span><span class="sd">"""Engine supports multiple pages."""</span>
|
|
|
|
<span class="n">time_range_support</span><span class="p">:</span> <span class="nb">bool</span>
|
|
<span class="w"> </span><span class="sd">"""Engine supports search time range."""</span>
|
|
|
|
<span class="n">safesearch</span><span class="p">:</span> <span class="nb">bool</span>
|
|
<span class="w"> </span><span class="sd">"""Engine supports SafeSearch"""</span>
|
|
|
|
<span class="n">language_support</span><span class="p">:</span> <span class="nb">bool</span>
|
|
<span class="w"> </span><span class="sd">"""Engine supports languages (locales) search."""</span>
|
|
|
|
<span class="n">language</span><span class="p">:</span> <span class="nb">str</span>
|
|
<span class="w"> </span><span class="sd">"""For an engine, when there is ``language: ...`` in the YAML settings the engine</span>
|
|
<span class="sd"> does support only this one language:</span>
|
|
|
|
<span class="sd"> .. code:: yaml</span>
|
|
|
|
<span class="sd"> - name: google french</span>
|
|
<span class="sd"> engine: google</span>
|
|
<span class="sd"> language: fr</span>
|
|
<span class="sd"> """</span>
|
|
|
|
<span class="n">region</span><span class="p">:</span> <span class="nb">str</span>
|
|
<span class="w"> </span><span class="sd">"""For an engine, when there is ``region: ...`` in the YAML settings the engine</span>
|
|
<span class="sd"> does support only this one region::</span>
|
|
|
|
<span class="sd"> .. code:: yaml</span>
|
|
|
|
<span class="sd"> - name: google belgium</span>
|
|
<span class="sd"> engine: google</span>
|
|
<span class="sd"> region: fr-BE</span>
|
|
<span class="sd"> """</span>
|
|
|
|
<span class="n">fetch_traits</span><span class="p">:</span> <span class="n">Callable</span>
|
|
<span class="w"> </span><span class="sd">"""Function to to fetch engine's traits from origin."""</span>
|
|
|
|
<span class="n">traits</span><span class="p">:</span> <span class="n">traits</span><span class="o">.</span><span class="n">EngineTraits</span>
|
|
<span class="w"> </span><span class="sd">"""Traits of the engine."""</span>
|
|
|
|
<span class="c1"># settings.yml</span>
|
|
|
|
<span class="n">categories</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span>
|
|
<span class="w"> </span><span class="sd">"""Specifies to which :ref:`engine categories` the engine should be added."""</span>
|
|
|
|
<span class="n">name</span><span class="p">:</span> <span class="nb">str</span>
|
|
<span class="w"> </span><span class="sd">"""Name that will be used across SearXNG to define this engine. In settings, on</span>
|
|
<span class="sd"> the result page .."""</span>
|
|
|
|
<span class="n">engine</span><span class="p">:</span> <span class="nb">str</span>
|
|
<span class="w"> </span><span class="sd">"""Name of the python file used to handle requests and responses to and from</span>
|
|
<span class="sd"> this search engine (file name from :origin:`searx/engines` without</span>
|
|
<span class="sd"> ``.py``)."""</span>
|
|
|
|
<span class="n">enable_http</span><span class="p">:</span> <span class="nb">bool</span>
|
|
<span class="w"> </span><span class="sd">"""Enable HTTP (by default only HTTPS is enabled)."""</span>
|
|
|
|
<span class="n">shortcut</span><span class="p">:</span> <span class="nb">str</span>
|
|
<span class="w"> </span><span class="sd">"""Code used to execute bang requests (``!foo``)"""</span>
|
|
|
|
<span class="n">timeout</span><span class="p">:</span> <span class="nb">float</span>
|
|
<span class="w"> </span><span class="sd">"""Specific timeout for search-engine."""</span>
|
|
|
|
<span class="n">display_error_messages</span><span class="p">:</span> <span class="nb">bool</span>
|
|
<span class="w"> </span><span class="sd">"""Display error messages on the web UI."""</span>
|
|
|
|
<span class="n">proxies</span><span class="p">:</span> <span class="nb">dict</span>
|
|
<span class="w"> </span><span class="sd">"""Set proxies for a specific engine (YAML):</span>
|
|
|
|
<span class="sd"> .. code:: yaml</span>
|
|
|
|
<span class="sd"> proxies :</span>
|
|
<span class="sd"> http: socks5://proxy:port</span>
|
|
<span class="sd"> https: socks5://proxy:port</span>
|
|
<span class="sd"> """</span>
|
|
|
|
<span class="n">disabled</span><span class="p">:</span> <span class="nb">bool</span>
|
|
<span class="w"> </span><span class="sd">"""To disable by default the engine, but not deleting it. It will allow the</span>
|
|
<span class="sd"> user to manually activate it in the settings."""</span>
|
|
|
|
<span class="n">inactive</span><span class="p">:</span> <span class="nb">bool</span>
|
|
<span class="w"> </span><span class="sd">"""Remove the engine from the settings (*disabled & removed*)."""</span>
|
|
|
|
<span class="n">about</span><span class="p">:</span> <span class="nb">dict</span>
|
|
<span class="w"> </span><span class="sd">"""Additional fields describing the engine.</span>
|
|
|
|
<span class="sd"> .. code:: yaml</span>
|
|
|
|
<span class="sd"> about:</span>
|
|
<span class="sd"> website: https://example.com</span>
|
|
<span class="sd"> wikidata_id: Q306656</span>
|
|
<span class="sd"> official_api_documentation: https://example.com/api-doc</span>
|
|
<span class="sd"> use_official_api: true</span>
|
|
<span class="sd"> require_api_key: true</span>
|
|
<span class="sd"> results: HTML</span>
|
|
<span class="sd"> """</span>
|
|
|
|
<span class="n">using_tor_proxy</span><span class="p">:</span> <span class="nb">bool</span>
|
|
<span class="w"> </span><span class="sd">"""Using tor proxy (``true``) or not (``false``) for this engine."""</span>
|
|
|
|
<span class="n">send_accept_language_header</span><span class="p">:</span> <span class="nb">bool</span>
|
|
<span class="w"> </span><span class="sd">"""When this option is activated, the language (locale) that is selected by</span>
|
|
<span class="sd"> the user is used to build and send a ``Accept-Language`` header in the</span>
|
|
<span class="sd"> request to the origin search engine."""</span>
|
|
|
|
<span class="n">tokens</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span>
|
|
<span class="w"> </span><span class="sd">"""A list of secret tokens to make this engine *private*, more details see</span>
|
|
<span class="sd"> :ref:`private engines`."""</span></div>
|
|
|
|
</pre></div>
|
|
|
|
<div class="clearer"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<span id="sidebar-top"></span>
|
|
<div class="sphinxsidebar" role="navigation" aria-label="Main">
|
|
<div class="sphinxsidebarwrapper">
|
|
|
|
|
|
<p class="logo"><a href="../../index.html">
|
|
<img class="logo" src="../../_static/searxng-wordmark.svg" alt="Logo of SearXNG"/>
|
|
</a></p>
|
|
|
|
|
|
<h3><a href="../../index.html">Table of Contents</a></h3>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../../user/index.html">User information</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="../../own-instance.html">Why use a private instance?</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="../../admin/index.html">Administrator documentation</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="../../dev/index.html">Developer documentation</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="../../utils/index.html">DevOps tooling box</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="../../src/index.html">Source-Code</a></li>
|
|
</ul>
|
|
|
|
<h3>Project Links</h3>
|
|
<ul>
|
|
<li><a href="https://github.com/searxng/searxng/tree/master">Source</a>
|
|
|
|
<li><a href="https://github.com/searxng/searxng/wiki">Wiki</a>
|
|
|
|
<li><a href="https://searx.space">Public instances</a>
|
|
|
|
<li><a href="https://github.com/searxng/searxng/issues">Issue Tracker</a>
|
|
</ul><h3>Navigation</h3>
|
|
<ul>
|
|
<li><a href="../../index.html">Overview</a>
|
|
<ul>
|
|
<li><a href="../index.html">Module code</a>
|
|
|
|
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
<search id="searchbox" style="display: none" role="search">
|
|
<h3 id="searchlabel">Quick search</h3>
|
|
<div class="searchformwrapper">
|
|
<form class="search" action="../../search.html" method="get">
|
|
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
|
<input type="submit" value="Go" />
|
|
</form>
|
|
</div>
|
|
</search>
|
|
<script>document.getElementById('searchbox').style.display = "block"</script>
|
|
</div>
|
|
</div>
|
|
<div class="clearer"></div>
|
|
</div>
|
|
<div class="footer" role="contentinfo">
|
|
© Copyright SearXNG team.
|
|
</div>
|
|
</body>
|
|
</html> |