summaryrefslogtreecommitdiff
path: root/_modules/searx/enginelib.html
blob: 4edeedf88bd3ec4ecb6c5ebd8816c610e9532096 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
<!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 &#8212; SearXNG Documentation (2024.5.10+ffb1001f8)</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/tabs.css?v=a5c4661c" />
    <script src="../../_static/documentation_options.js?v=ae3a6ae6"></script>
    <script src="../../_static/doctools.js?v=9a2dae69"></script>
    <script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
    <script src="../../_static/tabs.js?v=3030b3cb"></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 navigation">
      <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.5.10+ffb1001f8)</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../index.html" accesskey="U">Module code</a> &#187;</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">&quot;&quot;&quot;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">&quot;&quot;&quot;</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">&quot;&quot;&quot;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">    &quot;&quot;&quot;</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">&quot;&quot;&quot;Type of the engine (:ref:`searx.search.processors`)&quot;&quot;&quot;</span>

    <span class="n">paging</span><span class="p">:</span> <span class="nb">bool</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Engine supports multiple pages.&quot;&quot;&quot;</span>

    <span class="n">time_range_support</span><span class="p">:</span> <span class="nb">bool</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Engine supports search time range.&quot;&quot;&quot;</span>

    <span class="n">safesearch</span><span class="p">:</span> <span class="nb">bool</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Engine supports SafeSearch&quot;&quot;&quot;</span>

    <span class="n">language_support</span><span class="p">:</span> <span class="nb">bool</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Engine supports languages (locales) search.&quot;&quot;&quot;</span>

    <span class="n">language</span><span class="p">:</span> <span class="nb">str</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;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">    &quot;&quot;&quot;</span>

    <span class="n">region</span><span class="p">:</span> <span class="nb">str</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;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">    &quot;&quot;&quot;</span>

    <span class="n">fetch_traits</span><span class="p">:</span> <span class="n">Callable</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Function to to fetch engine&#39;s traits from origin.&quot;&quot;&quot;</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">&quot;&quot;&quot;Traits of the engine.&quot;&quot;&quot;</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">&quot;&quot;&quot;Specifies to which :ref:`engine categories` the engine should be added.&quot;&quot;&quot;</span>

    <span class="n">name</span><span class="p">:</span> <span class="nb">str</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Name that will be used across SearXNG to define this engine.  In settings, on</span>
<span class="sd">    the result page ..&quot;&quot;&quot;</span>

    <span class="n">engine</span><span class="p">:</span> <span class="nb">str</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;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``).&quot;&quot;&quot;</span>

    <span class="n">enable_http</span><span class="p">:</span> <span class="nb">bool</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Enable HTTP (by default only HTTPS is enabled).&quot;&quot;&quot;</span>

    <span class="n">shortcut</span><span class="p">:</span> <span class="nb">str</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Code used to execute bang requests (``!foo``)&quot;&quot;&quot;</span>

    <span class="n">timeout</span><span class="p">:</span> <span class="nb">float</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Specific timeout for search-engine.&quot;&quot;&quot;</span>

    <span class="n">display_error_messages</span><span class="p">:</span> <span class="nb">bool</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Display error messages on the web UI.&quot;&quot;&quot;</span>

    <span class="n">proxies</span><span class="p">:</span> <span class="nb">dict</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;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">    &quot;&quot;&quot;</span>

    <span class="n">disabled</span><span class="p">:</span> <span class="nb">bool</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;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.&quot;&quot;&quot;</span>

    <span class="n">inactive</span><span class="p">:</span> <span class="nb">bool</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Remove the engine from the settings (*disabled &amp; removed*).&quot;&quot;&quot;</span>

    <span class="n">about</span><span class="p">:</span> <span class="nb">dict</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;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">    &quot;&quot;&quot;</span>

    <span class="n">using_tor_proxy</span><span class="p">:</span> <span class="nb">bool</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;Using tor proxy (``true``) or not (``false``) for this engine.&quot;&quot;&quot;</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">&quot;&quot;&quot;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.&quot;&quot;&quot;</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">&quot;&quot;&quot;A list of secret tokens to make this engine *private*, more details see</span>
<span class="sd">    :ref:`private engines`.&quot;&quot;&quot;</span></div>

</pre></div>

            <div class="clearer"></div>
          </div>
        </div>
      </div>
  <span id="sidebar-top"></span>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  
    
            <p class="logo"><a href="../../index.html">
              <img class="logo" src="../../_static/searxng-wordmark.svg" alt="Logo"/>
            </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">
    &#169; Copyright SearXNG team.
    </div>
  <script src="../../_static/version_warning_offset.js"></script>

  </body>
</html>