summaryrefslogtreecommitdiff
path: root/src/searx.utils.html
blob: b432b620e0999ef06d77fb1ce3a2e171bc282ff7 (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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
<!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>Utility functions for the engines &#8212; SearXNG Documentation (2025.1.6+6dab7fe78)</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" />
    <script src="../_static/documentation_options.js?v=ef740023"></script>
    <script src="../_static/doctools.js?v=9a2dae69"></script>
    <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
    <script data-project="searxng" data-version="2025.1.6+6dab7fe78" src="../_static/describe_version.js?v=fa7f30d0"></script>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="prev" title="SQLite DB" href="searx.sqlitedb.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="right" >
          <a href="searx.sqlitedb.html" title="SQLite DB"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../index.html">SearXNG Documentation (2025.1.6+6dab7fe78)</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Source-Code</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">Utility functions for the engines</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="module-searx.utils">
<span id="utility-functions-for-the-engines"></span><span id="searx-utils"></span><h1>Utility functions for the engines<a class="headerlink" href="#module-searx.utils" title="Link to this heading"></a></h1>
<p>Utility functions for the engines</p>
<dl class="py function">
<dt class="sig sig-object py" id="searx.utils.convert_str_to_int">
<span class="sig-prename descclassname"><span class="pre">searx.utils.</span></span><span class="sig-name descname"><span class="pre">convert_str_to_int</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">number_str</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.13)"><span class="pre">int</span></a></span></span><a class="reference internal" href="../_modules/searx/utils.html#convert_str_to_int"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.utils.convert_str_to_int" title="Link to this definition"></a></dt>
<dd><p>Convert number_str to int or 0 if number_str is not a number.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="searx.utils.detect_language">
<span class="sig-prename descclassname"><span class="pre">searx.utils.</span></span><span class="sig-name descname"><span class="pre">detect_language</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">text</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">threshold</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.13)"><span class="pre">float</span></a></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">0.3</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">only_search_languages</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.13)"><span class="pre">bool</span></a></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(in Python v3.13)"><span class="pre">None</span></a></span></span><a class="reference internal" href="../_modules/searx/utils.html#detect_language"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.utils.detect_language" title="Link to this definition"></a></dt>
<dd><p>Detect the language of the <code class="docutils literal notranslate"><span class="pre">text</span></code> parameter.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>text</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><em>str</em></a>) – The string whose language is to be detected.</p></li>
<li><p><strong>threshold</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.13)"><em>float</em></a>) – Threshold filters the returned labels by a threshold
on probability.  A choice of 0.3 will return labels with at least 0.3
probability.</p></li>
<li><p><strong>only_search_languages</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.13)"><em>bool</em></a>) – If <code class="docutils literal notranslate"><span class="pre">True</span></code>, returns only supported
SearXNG search languages.  see <code class="xref py py-obj docutils literal notranslate"><span class="pre">searx.languages</span></code></p></li>
</ul>
</dd>
<dt class="field-even">Return type<span class="colon">:</span></dt>
<dd class="field-even"><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)">str</a>, None</p>
</dd>
<dt class="field-odd">Returns<span class="colon">:</span></dt>
<dd class="field-odd"><p>The detected language code or <code class="docutils literal notranslate"><span class="pre">None</span></code>. See below.</p>
</dd>
<dt class="field-even">Raises<span class="colon">:</span></dt>
<dd class="field-even"><p><a class="reference external" href="https://docs.python.org/3/library/exceptions.html#ValueError" title="(in Python v3.13)"><strong>ValueError</strong></a> – If <code class="docutils literal notranslate"><span class="pre">text</span></code> is not a string.</p>
</dd>
</dl>
<p>The language detection is done by using <a class="reference external" href="https://github.com/searxng/fasttext-predict">a fork</a> of the <a class="reference external" href="https://fasttext.cc/">fastText</a> library
(<a class="reference external" href="https://pypi.org/project/fasttext/">python fasttext</a>). <a class="reference external" href="https://fasttext.cc/">fastText</a> distributes the <a class="reference external" href="https://fasttext.cc/docs/en/language-identification.html">language identification
model</a>, for reference:</p>
<ul class="simple">
<li><p><a class="reference external" href="https://arxiv.org/abs/1612.03651">FastText.zip: Compressing text classification models</a></p></li>
<li><p><a class="reference external" href="https://arxiv.org/abs/1607.01759">Bag of Tricks for Efficient Text Classification</a></p></li>
</ul>
<p>The <a class="reference external" href="https://fasttext.cc/docs/en/language-identification.html">language identification model</a> support the language codes
(ISO-639-3):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">af</span> <span class="n">als</span> <span class="n">am</span> <span class="n">an</span> <span class="n">ar</span> <span class="n">arz</span> <span class="k">as</span> <span class="n">ast</span> <span class="n">av</span> <span class="n">az</span> <span class="n">azb</span> <span class="n">ba</span> <span class="n">bar</span> <span class="n">bcl</span> <span class="n">be</span> <span class="n">bg</span> <span class="n">bh</span> <span class="n">bn</span> <span class="n">bo</span> <span class="n">bpy</span> <span class="n">br</span> <span class="n">bs</span>
<span class="n">bxr</span> <span class="n">ca</span> <span class="n">cbk</span> <span class="n">ce</span> <span class="n">ceb</span> <span class="n">ckb</span> <span class="n">co</span> <span class="n">cs</span> <span class="n">cv</span> <span class="n">cy</span> <span class="n">da</span> <span class="n">de</span> <span class="n">diq</span> <span class="n">dsb</span> <span class="n">dty</span> <span class="n">dv</span> <span class="n">el</span> <span class="n">eml</span> <span class="n">en</span> <span class="n">eo</span> <span class="n">es</span>
<span class="n">et</span> <span class="n">eu</span> <span class="n">fa</span> <span class="n">fi</span> <span class="n">fr</span> <span class="n">frr</span> <span class="n">fy</span> <span class="n">ga</span> <span class="n">gd</span> <span class="n">gl</span> <span class="n">gn</span> <span class="n">gom</span> <span class="n">gu</span> <span class="n">gv</span> <span class="n">he</span> <span class="n">hi</span> <span class="n">hif</span> <span class="n">hr</span> <span class="n">hsb</span> <span class="n">ht</span> <span class="n">hu</span> <span class="n">hy</span> <span class="n">ia</span>
<span class="nb">id</span> <span class="n">ie</span> <span class="n">ilo</span> <span class="n">io</span> <span class="ow">is</span> <span class="n">it</span> <span class="n">ja</span> <span class="n">jbo</span> <span class="n">jv</span> <span class="n">ka</span> <span class="n">kk</span> <span class="n">km</span> <span class="n">kn</span> <span class="n">ko</span> <span class="n">krc</span> <span class="n">ku</span> <span class="n">kv</span> <span class="n">kw</span> <span class="n">ky</span> <span class="n">la</span> <span class="n">lb</span> <span class="n">lez</span> <span class="n">li</span>
<span class="n">lmo</span> <span class="n">lo</span> <span class="n">lrc</span> <span class="n">lt</span> <span class="n">lv</span> <span class="n">mai</span> <span class="n">mg</span> <span class="n">mhr</span> <span class="nb">min</span> <span class="n">mk</span> <span class="n">ml</span> <span class="n">mn</span> <span class="n">mr</span> <span class="n">mrj</span> <span class="n">ms</span> <span class="n">mt</span> <span class="n">mwl</span> <span class="n">my</span> <span class="n">myv</span> <span class="n">mzn</span> <span class="n">nah</span>
<span class="n">nap</span> <span class="n">nds</span> <span class="n">ne</span> <span class="n">new</span> <span class="n">nl</span> <span class="n">nn</span> <span class="n">no</span> <span class="n">oc</span> <span class="ow">or</span> <span class="n">os</span> <span class="n">pa</span> <span class="n">pam</span> <span class="n">pfl</span> <span class="n">pl</span> <span class="n">pms</span> <span class="n">pnb</span> <span class="n">ps</span> <span class="n">pt</span> <span class="n">qu</span> <span class="n">rm</span> <span class="n">ro</span> <span class="n">ru</span>
<span class="n">rue</span> <span class="n">sa</span> <span class="n">sah</span> <span class="n">sc</span> <span class="n">scn</span> <span class="n">sco</span> <span class="n">sd</span> <span class="n">sh</span> <span class="n">si</span> <span class="n">sk</span> <span class="n">sl</span> <span class="n">so</span> <span class="n">sq</span> <span class="n">sr</span> <span class="n">su</span> <span class="n">sv</span> <span class="n">sw</span> <span class="n">ta</span> <span class="n">te</span> <span class="n">tg</span> <span class="n">th</span> <span class="n">tk</span> <span class="n">tl</span>
<span class="n">tr</span> <span class="n">tt</span> <span class="n">tyv</span> <span class="n">ug</span> <span class="n">uk</span> <span class="n">ur</span> <span class="n">uz</span> <span class="n">vec</span> <span class="n">vep</span> <span class="n">vi</span> <span class="n">vls</span> <span class="n">vo</span> <span class="n">wa</span> <span class="n">war</span> <span class="n">wuu</span> <span class="n">xal</span> <span class="n">xmf</span> <span class="n">yi</span> <span class="n">yo</span> <span class="n">yue</span> <span class="n">zh</span>
</pre></div>
</div>
<p>By using <code class="docutils literal notranslate"><span class="pre">only_search_languages=True</span></code> the <a class="reference external" href="https://fasttext.cc/docs/en/language-identification.html">language identification model</a>
is harmonized with the SearXNG’s language (locale) model.  General
conditions of SearXNG’s locale model are:</p>
<ol class="loweralpha simple">
<li><p>SearXNG’s locale of a query is passed to the
<a class="reference internal" href="searx.locales.html#searx.locales.get_engine_locale" title="searx.locales.get_engine_locale"><code class="xref py py-obj docutils literal notranslate"><span class="pre">searx.locales.get_engine_locale</span></code></a> to get a language and/or region
code that is used by an engine.</p></li>
<li><p>Most of SearXNG’s engines do not support all the languages from <a class="reference external" href="https://fasttext.cc/docs/en/language-identification.html">language
identification model</a> and there is also a discrepancy in the ISO-639-3
(fasttext) and ISO-639-2 (SearXNG)handling.  Further more, in SearXNG the
locales like <code class="docutils literal notranslate"><span class="pre">zh-TH</span></code> (<code class="docutils literal notranslate"><span class="pre">zh-CN</span></code>) are mapped to <code class="docutils literal notranslate"><span class="pre">zh_Hant</span></code>
(<code class="docutils literal notranslate"><span class="pre">zh_Hans</span></code>) while the <a class="reference external" href="https://fasttext.cc/docs/en/language-identification.html">language identification model</a> reduce both to
<code class="docutils literal notranslate"><span class="pre">zh</span></code>.</p></li>
</ol>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="searx.utils.dict_subset">
<span class="sig-prename descclassname"><span class="pre">searx.utils.</span></span><span class="sig-name descname"><span class="pre">dict_subset</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dictionary</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.MutableMapping" title="(in Python v3.13)"><span class="pre">MutableMapping</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">properties</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Set" title="(in Python v3.13)"><span class="pre">Set</span></a><span class="p"><span class="pre">[</span></span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a><span class="p"><span class="pre">]</span></span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Dict" title="(in Python v3.13)"><span class="pre">Dict</span></a></span></span><a class="reference internal" href="../_modules/searx/utils.html#dict_subset"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.utils.dict_subset" title="Link to this definition"></a></dt>
<dd><p>Extract a subset of a dict</p>
<dl>
<dt>Examples:</dt><dd><div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">dict_subset</span><span class="p">({</span><span class="s1">&#39;A&#39;</span><span class="p">:</span> <span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;B&#39;</span><span class="p">:</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;C&#39;</span><span class="p">:</span> <span class="s1">&#39;c&#39;</span><span class="p">},</span> <span class="p">[</span><span class="s1">&#39;A&#39;</span><span class="p">,</span> <span class="s1">&#39;C&#39;</span><span class="p">])</span>
<span class="go">{&#39;A&#39;: &#39;a&#39;, &#39;C&#39;: &#39;c&#39;}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="o">&gt;&gt;</span> <span class="n">dict_subset</span><span class="p">({</span><span class="s1">&#39;A&#39;</span><span class="p">:</span> <span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;B&#39;</span><span class="p">:</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;C&#39;</span><span class="p">:</span> <span class="s1">&#39;c&#39;</span><span class="p">},</span> <span class="p">[</span><span class="s1">&#39;A&#39;</span><span class="p">,</span> <span class="s1">&#39;D&#39;</span><span class="p">])</span>
<span class="go">{&#39;A&#39;: &#39;a&#39;}</span>
</pre></div>
</div>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="searx.utils.ecma_unescape">
<span class="sig-prename descclassname"><span class="pre">searx.utils.</span></span><span class="sig-name descname"><span class="pre">ecma_unescape</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">string</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a></span></span><a class="reference internal" href="../_modules/searx/utils.html#ecma_unescape"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.utils.ecma_unescape" title="Link to this definition"></a></dt>
<dd><p>Python implementation of the unescape javascript function</p>
<p><a class="reference external" href="https://www.ecma-international.org/ecma-262/6.0/#sec-unescape-string">https://www.ecma-international.org/ecma-262/6.0/#sec-unescape-string</a>
<a class="reference external" href="https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/unescape">https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/unescape</a></p>
<dl>
<dt>Examples:</dt><dd><div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">ecma_unescape</span><span class="p">(</span><span class="s1">&#39;</span><span class="si">%u</span><span class="s1">5409&#39;</span><span class="p">)</span>
<span class="go">&#39;&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ecma_unescape</span><span class="p">(</span><span class="s1">&#39;%20&#39;</span><span class="p">)</span>
<span class="go">&#39; &#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ecma_unescape</span><span class="p">(</span><span class="s1">&#39;</span><span class="si">%F</span><span class="s1">3&#39;</span><span class="p">)</span>
<span class="go">&#39;ó&#39;</span>
</pre></div>
</div>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="searx.utils.eval_xpath">
<span class="sig-prename descclassname"><span class="pre">searx.utils.</span></span><span class="sig-name descname"><span class="pre">eval_xpath</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">element</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">ElementBase</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xpath_spec</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">XPath</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/utils.html#eval_xpath"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.utils.eval_xpath" title="Link to this definition"></a></dt>
<dd><p>Equivalent of element.xpath(xpath_str) but compile xpath_str once for all.
See <a class="reference external" href="https://lxml.de/xpathxslt.html#xpath-return-values">https://lxml.de/xpathxslt.html#xpath-return-values</a></p>
<dl class="simple">
<dt>Args:</dt><dd><ul class="simple">
<li><p>element (ElementBase): [description]</p></li>
<li><p>xpath_spec (str|lxml.etree.XPath): XPath as a str or lxml.etree.XPath</p></li>
</ul>
</dd>
<dt>Returns:</dt><dd><ul class="simple">
<li><p>result (bool, float, list, str): Results.</p></li>
</ul>
</dd>
<dt>Raises:</dt><dd><ul class="simple">
<li><p>TypeError: Raise when xpath_spec is neither a str nor a lxml.etree.XPath</p></li>
<li><p>SearxXPathSyntaxException: Raise when there is a syntax error in the XPath</p></li>
<li><p>SearxEngineXPathException: Raise when the XPath can’t be evaluated.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="searx.utils.eval_xpath_getindex">
<span class="sig-prename descclassname"><span class="pre">searx.utils.</span></span><span class="sig-name descname"><span class="pre">eval_xpath_getindex</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">elements:</span> <span class="pre">~lxml.etree.ElementBase</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xpath_spec:</span> <span class="pre">str</span> <span class="pre">|</span> <span class="pre">~lxml.etree.XPath</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">index:</span> <span class="pre">int</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">default=&lt;searx.utils._NotSetClass</span> <span class="pre">object&gt;</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/utils.html#eval_xpath_getindex"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.utils.eval_xpath_getindex" title="Link to this definition"></a></dt>
<dd><p>Call eval_xpath_list then get one element using the index parameter.
If the index does not exist, either raise an exception is default is not set,
other return the default value (can be None).</p>
<dl class="simple">
<dt>Args:</dt><dd><ul class="simple">
<li><p>elements (ElementBase): lxml element to apply the xpath.</p></li>
<li><p>xpath_spec (str|lxml.etree.XPath): XPath as a str or lxml.etree.XPath.</p></li>
<li><p>index (int): index to get</p></li>
<li><p>default (Object, optional): Defaults if index doesn’t exist.</p></li>
</ul>
</dd>
<dt>Raises:</dt><dd><ul class="simple">
<li><p>TypeError: Raise when xpath_spec is neither a str nor a lxml.etree.XPath</p></li>
<li><p>SearxXPathSyntaxException: Raise when there is a syntax error in the XPath</p></li>
<li><p>SearxEngineXPathException: if the index is not found. Also see eval_xpath.</p></li>
</ul>
</dd>
<dt>Returns:</dt><dd><ul class="simple">
<li><p>result (bool, float, list, str): Results.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="searx.utils.eval_xpath_list">
<span class="sig-prename descclassname"><span class="pre">searx.utils.</span></span><span class="sig-name descname"><span class="pre">eval_xpath_list</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">element</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">ElementBase</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xpath_spec</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">XPath</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">min_len</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.13)"><span class="pre">int</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(in Python v3.13)"><span class="pre">None</span></a></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/utils.html#eval_xpath_list"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.utils.eval_xpath_list" title="Link to this definition"></a></dt>
<dd><p>Same as eval_xpath, check if the result is a list</p>
<dl class="simple">
<dt>Args:</dt><dd><ul class="simple">
<li><p>element (ElementBase): [description]</p></li>
<li><p>xpath_spec (str|lxml.etree.XPath): XPath as a str or lxml.etree.XPath</p></li>
<li><p>min_len (int, optional): [description]. Defaults to None.</p></li>
</ul>
</dd>
<dt>Raises:</dt><dd><ul class="simple">
<li><p>TypeError: Raise when xpath_spec is neither a str nor a lxml.etree.XPath</p></li>
<li><p>SearxXPathSyntaxException: Raise when there is a syntax error in the XPath</p></li>
<li><p>SearxEngineXPathException: raise if the result is not a list</p></li>
</ul>
</dd>
<dt>Returns:</dt><dd><ul class="simple">
<li><p>result (bool, float, list, str): Results.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="searx.utils.extr">
<span class="sig-prename descclassname"><span class="pre">searx.utils.</span></span><span class="sig-name descname"><span class="pre">extr</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">txt</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">begin</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">end</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">default</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/utils.html#extr"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.utils.extr" title="Link to this definition"></a></dt>
<dd><p>Extract the string between <code class="docutils literal notranslate"><span class="pre">begin</span></code> and <code class="docutils literal notranslate"><span class="pre">end</span></code> from <code class="docutils literal notranslate"><span class="pre">txt</span></code></p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>txt</strong> – String to search in</p></li>
<li><p><strong>begin</strong> – First string to be searched for</p></li>
<li><p><strong>end</strong> – Second string to be searched for after <code class="docutils literal notranslate"><span class="pre">begin</span></code></p></li>
<li><p><strong>default</strong> – Default value if one of <code class="docutils literal notranslate"><span class="pre">begin</span></code> or <code class="docutils literal notranslate"><span class="pre">end</span></code> is not
found.  Defaults to an empty string.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>The string between the two search-strings <code class="docutils literal notranslate"><span class="pre">begin</span></code> and <code class="docutils literal notranslate"><span class="pre">end</span></code>.
If at least one of <code class="docutils literal notranslate"><span class="pre">begin</span></code> or <code class="docutils literal notranslate"><span class="pre">end</span></code> is not found, the value of
<code class="docutils literal notranslate"><span class="pre">default</span></code> is returned.</p>
</dd>
</dl>
<dl>
<dt>Examples:</dt><dd><div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">extr</span><span class="p">(</span><span class="s2">&quot;abcde&quot;</span><span class="p">,</span> <span class="s2">&quot;a&quot;</span><span class="p">,</span> <span class="s2">&quot;e&quot;</span><span class="p">)</span>
<span class="go">&quot;bcd&quot;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">extr</span><span class="p">(</span><span class="s2">&quot;abcde&quot;</span><span class="p">,</span> <span class="s2">&quot;a&quot;</span><span class="p">,</span> <span class="s2">&quot;z&quot;</span><span class="p">,</span> <span class="n">deafult</span><span class="o">=</span><span class="s2">&quot;nothing&quot;</span><span class="p">)</span>
<span class="go">&quot;nothing&quot;</span>
</pre></div>
</div>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="searx.utils.extract_text">
<span class="sig-prename descclassname"><span class="pre">searx.utils.</span></span><span class="sig-name descname"><span class="pre">extract_text</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">xpath_results</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">allow_none</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.13)"><span class="pre">bool</span></a></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(in Python v3.13)"><span class="pre">None</span></a></span></span><a class="reference internal" href="../_modules/searx/utils.html#extract_text"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.utils.extract_text" title="Link to this definition"></a></dt>
<dd><p>Extract text from a lxml result</p>
<ul class="simple">
<li><p>if xpath_results is list, extract the text from each result and concat the list</p></li>
<li><p>if xpath_results is a xml element, extract all the text node from it
( text_content() method from lxml )</p></li>
<li><p>if xpath_results is a string element, then it’s already done</p></li>
</ul>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="searx.utils.extract_url">
<span class="sig-prename descclassname"><span class="pre">searx.utils.</span></span><span class="sig-name descname"><span class="pre">extract_url</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">xpath_results</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">base_url</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a></span></span><a class="reference internal" href="../_modules/searx/utils.html#extract_url"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.utils.extract_url" title="Link to this definition"></a></dt>
<dd><p>Extract and normalize URL from lxml Element</p>
<dl>
<dt>Args:</dt><dd><ul class="simple">
<li><p>xpath_results (Union[List[html.HtmlElement], html.HtmlElement]): lxml Element(s)</p></li>
<li><p>base_url (str): Base URL</p></li>
</ul>
</dd>
<dt>Example:</dt><dd><div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="k">def</span> <span class="nf">f</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">search_url</span><span class="p">):</span>
<span class="gp">&gt;&gt;&gt; </span>   <span class="k">return</span> <span class="n">searx</span><span class="o">.</span><span class="n">utils</span><span class="o">.</span><span class="n">extract_url</span><span class="p">(</span><span class="n">html</span><span class="o">.</span><span class="n">fromstring</span><span class="p">(</span><span class="n">s</span><span class="p">),</span> <span class="n">search_url</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="p">(</span><span class="s1">&#39;&lt;span id=&quot;42&quot;&gt;https://example.com&lt;/span&gt;&#39;</span><span class="p">,</span> <span class="s1">&#39;http://example.com/&#39;</span><span class="p">)</span>
<span class="go">&#39;https://example.com/&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="p">(</span><span class="s1">&#39;https://example.com&#39;</span><span class="p">,</span> <span class="s1">&#39;http://example.com/&#39;</span><span class="p">)</span>
<span class="go">&#39;https://example.com/&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="p">(</span><span class="s1">&#39;//example.com&#39;</span><span class="p">,</span> <span class="s1">&#39;http://example.com/&#39;</span><span class="p">)</span>
<span class="go">&#39;http://example.com/&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="p">(</span><span class="s1">&#39;//example.com&#39;</span><span class="p">,</span> <span class="s1">&#39;https://example.com/&#39;</span><span class="p">)</span>
<span class="go">&#39;https://example.com/&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="p">(</span><span class="s1">&#39;/path?a=1&#39;</span><span class="p">,</span> <span class="s1">&#39;https://example.com&#39;</span><span class="p">)</span>
<span class="go">&#39;https://example.com/path?a=1&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span><span class="p">(</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;https://example.com&#39;</span><span class="p">)</span>
<span class="go">raise lxml.etree.ParserError</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">searx</span><span class="o">.</span><span class="n">utils</span><span class="o">.</span><span class="n">extract_url</span><span class="p">([],</span> <span class="s1">&#39;https://example.com&#39;</span><span class="p">)</span>
<span class="go">raise ValueError</span>
</pre></div>
</div>
</dd>
<dt>Raises:</dt><dd><ul class="simple">
<li><p>ValueError</p></li>
<li><p>lxml.etree.ParserError</p></li>
</ul>
</dd>
<dt>Returns:</dt><dd><ul class="simple">
<li><p>str: normalized URL</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="searx.utils.gen_useragent">
<span class="sig-prename descclassname"><span class="pre">searx.utils.</span></span><span class="sig-name descname"><span class="pre">gen_useragent</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">os_string</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(in Python v3.13)"><span class="pre">None</span></a></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a></span></span><a class="reference internal" href="../_modules/searx/utils.html#gen_useragent"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.utils.gen_useragent" title="Link to this definition"></a></dt>
<dd><p>Return a random browser User Agent</p>
<p>See searx/data/useragents.json</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="searx.utils.get_embeded_stream_url">
<span class="sig-prename descclassname"><span class="pre">searx.utils.</span></span><span class="sig-name descname"><span class="pre">get_embeded_stream_url</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">url</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/utils.html#get_embeded_stream_url"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.utils.get_embeded_stream_url" title="Link to this definition"></a></dt>
<dd><p>Converts a standard video URL into its embed format. Supported services include Youtube,
Facebook, Instagram, TikTok, and Dailymotion.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="searx.utils.get_engine_from_settings">
<span class="sig-prename descclassname"><span class="pre">searx.utils.</span></span><span class="sig-name descname"><span class="pre">get_engine_from_settings</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Dict" title="(in Python v3.13)"><span class="pre">Dict</span></a></span></span><a class="reference internal" href="../_modules/searx/utils.html#get_engine_from_settings"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.utils.get_engine_from_settings" title="Link to this definition"></a></dt>
<dd><p>Return engine configuration from settings.yml of a given engine name</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="searx.utils.get_xpath">
<span class="sig-prename descclassname"><span class="pre">searx.utils.</span></span><span class="sig-name descname"><span class="pre">get_xpath</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">xpath_spec</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">XPath</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">XPath</span></span></span><a class="reference internal" href="../_modules/searx/utils.html#get_xpath"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.utils.get_xpath" title="Link to this definition"></a></dt>
<dd><p>Return cached compiled XPath</p>
<p>There is no thread lock.
Worst case scenario, xpath_str is compiled more than one time.</p>
<dl class="simple">
<dt>Args:</dt><dd><ul class="simple">
<li><p>xpath_spec (str|lxml.etree.XPath): XPath as a str or lxml.etree.XPath</p></li>
</ul>
</dd>
<dt>Returns:</dt><dd><ul class="simple">
<li><p>result (bool, float, list, str): Results.</p></li>
</ul>
</dd>
<dt>Raises:</dt><dd><ul class="simple">
<li><p>TypeError: Raise when xpath_spec is neither a str nor a lxml.etree.XPath</p></li>
<li><p>SearxXPathSyntaxException: Raise when there is a syntax error in the XPath</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="searx.utils.html_to_text">
<span class="sig-prename descclassname"><span class="pre">searx.utils.</span></span><span class="sig-name descname"><span class="pre">html_to_text</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">html_str</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a></span></span><a class="reference internal" href="../_modules/searx/utils.html#html_to_text"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.utils.html_to_text" title="Link to this definition"></a></dt>
<dd><p>Extract text from a HTML string</p>
<dl>
<dt>Args:</dt><dd><ul class="simple">
<li><p>html_str (str): string HTML</p></li>
</ul>
</dd>
<dt>Returns:</dt><dd><ul class="simple">
<li><p>str: extracted text</p></li>
</ul>
</dd>
<dt>Examples:</dt><dd><div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">html_to_text</span><span class="p">(</span><span class="s1">&#39;Example &lt;span id=&quot;42&quot;&gt;#2&lt;/span&gt;&#39;</span><span class="p">)</span>
<span class="go">&#39;Example #2&#39;</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">html_to_text</span><span class="p">(</span><span class="s1">&#39;&lt;style&gt;.span { color: red; }&lt;/style&gt;&lt;span&gt;Example&lt;/span&gt;&#39;</span><span class="p">)</span>
<span class="go">&#39;Example&#39;</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">html_to_text</span><span class="p">(</span><span class="sa">r</span><span class="s1">&#39;regexp: (?&lt;![a-zA-Z]&#39;</span><span class="p">)</span>
<span class="go">&#39;regexp: (?&lt;![a-zA-Z]&#39;</span>
</pre></div>
</div>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="searx.utils.humanize_bytes">
<span class="sig-prename descclassname"><span class="pre">searx.utils.</span></span><span class="sig-name descname"><span class="pre">humanize_bytes</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">size</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">precision</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">2</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/utils.html#humanize_bytes"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.utils.humanize_bytes" title="Link to this definition"></a></dt>
<dd><p>Determine the <em>human readable</em> value of bytes on 1024 base (1KB=1024B).</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="searx.utils.humanize_number">
<span class="sig-prename descclassname"><span class="pre">searx.utils.</span></span><span class="sig-name descname"><span class="pre">humanize_number</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">size</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">precision</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/utils.html#humanize_number"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.utils.humanize_number" title="Link to this definition"></a></dt>
<dd><p>Determine the <em>human readable</em> value of a decimal number.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="searx.utils.int_or_zero">
<span class="sig-prename descclassname"><span class="pre">searx.utils.</span></span><span class="sig-name descname"><span class="pre">int_or_zero</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">num</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.List" title="(in Python v3.13)"><span class="pre">List</span></a><span class="p"><span class="pre">[</span></span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.13)"><span class="pre">int</span></a></span></span><a class="reference internal" href="../_modules/searx/utils.html#int_or_zero"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.utils.int_or_zero" title="Link to this definition"></a></dt>
<dd><p>Convert num to int or 0. num can be either a str or a list.
If num is a list, the first element is converted to int (or return 0 if the list is empty).
If num is a str, see convert_str_to_int</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="searx.utils.is_valid_lang">
<span class="sig-prename descclassname"><span class="pre">searx.utils.</span></span><span class="sig-name descname"><span class="pre">is_valid_lang</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">lang</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Tuple" title="(in Python v3.13)"><span class="pre">Tuple</span></a><span class="p"><span class="pre">[</span></span><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.13)"><span class="pre">bool</span></a><span class="p"><span class="pre">,</span></span><span class="w"> </span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a><span class="p"><span class="pre">,</span></span><span class="w"> </span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(in Python v3.13)"><span class="pre">None</span></a></span></span><a class="reference internal" href="../_modules/searx/utils.html#is_valid_lang"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.utils.is_valid_lang" title="Link to this definition"></a></dt>
<dd><p>Return language code and name if lang describe a language.</p>
<dl>
<dt>Examples:</dt><dd><div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">is_valid_lang</span><span class="p">(</span><span class="s1">&#39;zz&#39;</span><span class="p">)</span>
<span class="go">None</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">is_valid_lang</span><span class="p">(</span><span class="s1">&#39;uk&#39;</span><span class="p">)</span>
<span class="go">(True, &#39;uk&#39;, &#39;ukrainian&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">is_valid_lang</span><span class="p">(</span><span class="sa">b</span><span class="s1">&#39;uk&#39;</span><span class="p">)</span>
<span class="go">(True, &#39;uk&#39;, &#39;ukrainian&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">is_valid_lang</span><span class="p">(</span><span class="s1">&#39;en&#39;</span><span class="p">)</span>
<span class="go">(True, &#39;en&#39;, &#39;english&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">searx</span><span class="o">.</span><span class="n">utils</span><span class="o">.</span><span class="n">is_valid_lang</span><span class="p">(</span><span class="s1">&#39;Español&#39;</span><span class="p">)</span>
<span class="go">(True, &#39;es&#39;, &#39;spanish&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">searx</span><span class="o">.</span><span class="n">utils</span><span class="o">.</span><span class="n">is_valid_lang</span><span class="p">(</span><span class="s1">&#39;Spanish&#39;</span><span class="p">)</span>
<span class="go">(True, &#39;es&#39;, &#39;spanish&#39;)</span>
</pre></div>
</div>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="searx.utils.js_variable_to_python">
<span class="sig-prename descclassname"><span class="pre">searx.utils.</span></span><span class="sig-name descname"><span class="pre">js_variable_to_python</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">js_variable</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/utils.html#js_variable_to_python"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.utils.js_variable_to_python" title="Link to this definition"></a></dt>
<dd><p>Convert a javascript variable into JSON and then load the value</p>
<p>It does not deal with all cases, but it is good enough for now.
chompjs has a better implementation.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="searx.utils.markdown_to_text">
<span class="sig-prename descclassname"><span class="pre">searx.utils.</span></span><span class="sig-name descname"><span class="pre">markdown_to_text</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">markdown_str</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a></span></span><a class="reference internal" href="../_modules/searx/utils.html#markdown_to_text"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.utils.markdown_to_text" title="Link to this definition"></a></dt>
<dd><p>Extract text from a Markdown string</p>
<dl>
<dt>Args:</dt><dd><ul class="simple">
<li><p>markdown_str (str): string Markdown</p></li>
</ul>
</dd>
<dt>Returns:</dt><dd><ul class="simple">
<li><p>str: extracted text</p></li>
</ul>
</dd>
<dt>Examples:</dt><dd><div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">markdown_to_text</span><span class="p">(</span><span class="s1">&#39;[example](https://example.com)&#39;</span><span class="p">)</span>
<span class="go">&#39;example&#39;</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">markdown_to_text</span><span class="p">(</span><span class="s1">&#39;## Headline&#39;</span><span class="p">)</span>
<span class="go">&#39;Headline&#39;</span>
</pre></div>
</div>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="searx.utils.normalize_url">
<span class="sig-prename descclassname"><span class="pre">searx.utils.</span></span><span class="sig-name descname"><span class="pre">normalize_url</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">url</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">base_url</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a></span></span><a class="reference internal" href="../_modules/searx/utils.html#normalize_url"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.utils.normalize_url" title="Link to this definition"></a></dt>
<dd><p>Normalize URL: add protocol, join URL with base_url, add trailing slash if there is no path</p>
<dl>
<dt>Args:</dt><dd><ul class="simple">
<li><p>url (str): Relative URL</p></li>
<li><p>base_url (str): Base URL, it must be an absolute URL.</p></li>
</ul>
</dd>
<dt>Example:</dt><dd><div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">normalize_url</span><span class="p">(</span><span class="s1">&#39;https://example.com&#39;</span><span class="p">,</span> <span class="s1">&#39;http://example.com/&#39;</span><span class="p">)</span>
<span class="go">&#39;https://example.com/&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">normalize_url</span><span class="p">(</span><span class="s1">&#39;//example.com&#39;</span><span class="p">,</span> <span class="s1">&#39;http://example.com/&#39;</span><span class="p">)</span>
<span class="go">&#39;http://example.com/&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">normalize_url</span><span class="p">(</span><span class="s1">&#39;//example.com&#39;</span><span class="p">,</span> <span class="s1">&#39;https://example.com/&#39;</span><span class="p">)</span>
<span class="go">&#39;https://example.com/&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">normalize_url</span><span class="p">(</span><span class="s1">&#39;/path?a=1&#39;</span><span class="p">,</span> <span class="s1">&#39;https://example.com&#39;</span><span class="p">)</span>
<span class="go">&#39;https://example.com/path?a=1&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">normalize_url</span><span class="p">(</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;https://example.com&#39;</span><span class="p">)</span>
<span class="go">&#39;https://example.com/&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">normalize_url</span><span class="p">(</span><span class="s1">&#39;/test&#39;</span><span class="p">,</span> <span class="s1">&#39;/path&#39;</span><span class="p">)</span>
<span class="go">raise ValueError</span>
</pre></div>
</div>
</dd>
<dt>Raises:</dt><dd><ul class="simple">
<li><p>lxml.etree.ParserError</p></li>
</ul>
</dd>
<dt>Returns:</dt><dd><ul class="simple">
<li><p>str: normalized URL</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="searx.utils.searx_useragent">
<span class="sig-prename descclassname"><span class="pre">searx.utils.</span></span><span class="sig-name descname"><span class="pre">searx_useragent</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a></span></span><a class="reference internal" href="../_modules/searx/utils.html#searx_useragent"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.utils.searx_useragent" title="Link to this definition"></a></dt>
<dd><p>Return the searx User Agent</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="searx.utils.to_string">
<span class="sig-prename descclassname"><span class="pre">searx.utils.</span></span><span class="sig-name descname"><span class="pre">to_string</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">obj</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Any" title="(in Python v3.13)"><span class="pre">Any</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a></span></span><a class="reference internal" href="../_modules/searx/utils.html#to_string"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.utils.to_string" title="Link to this definition"></a></dt>
<dd><p>Convert obj to its string representation.</p>
</dd></dl>

<dl class="py data">
<dt class="sig sig-object py" id="searx.utils.SEARCH_LANGUAGE_CODES">
<span class="sig-prename descclassname"><span class="pre">searx.utils.</span></span><span class="sig-name descname"><span class="pre">SEARCH_LANGUAGE_CODES</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">frozenset({'af',</span> <span class="pre">'ar',</span> <span class="pre">'be',</span> <span class="pre">'bg',</span> <span class="pre">'ca',</span> <span class="pre">'cs',</span> <span class="pre">'cy',</span> <span class="pre">'da',</span> <span class="pre">'de',</span> <span class="pre">'el',</span> <span class="pre">'en',</span> <span class="pre">'es',</span> <span class="pre">'et',</span> <span class="pre">'fa',</span> <span class="pre">'fi',</span> <span class="pre">'fr',</span> <span class="pre">'ga',</span> <span class="pre">'gd',</span> <span class="pre">'gl',</span> <span class="pre">'he',</span> <span class="pre">'hi',</span> <span class="pre">'hr',</span> <span class="pre">'hu',</span> <span class="pre">'id',</span> <span class="pre">'it',</span> <span class="pre">'ja',</span> <span class="pre">'kn',</span> <span class="pre">'ko',</span> <span class="pre">'lt',</span> <span class="pre">'lv',</span> <span class="pre">'ml',</span> <span class="pre">'mr',</span> <span class="pre">'nb',</span> <span class="pre">'nl',</span> <span class="pre">'pl',</span> <span class="pre">'pt',</span> <span class="pre">'ro',</span> <span class="pre">'ru',</span> <span class="pre">'sk',</span> <span class="pre">'sl',</span> <span class="pre">'sq',</span> <span class="pre">'sv',</span> <span class="pre">'ta',</span> <span class="pre">'te',</span> <span class="pre">'th',</span> <span class="pre">'tr',</span> <span class="pre">'uk',</span> <span class="pre">'ur',</span> <span class="pre">'vi',</span> <span class="pre">'zh'})</span></em><a class="headerlink" href="#searx.utils.SEARCH_LANGUAGE_CODES" title="Link to this definition"></a></dt>
<dd><p>Languages supported by most searxng engines (<a class="reference internal" href="searx.locales.html#searx.sxng_locales.sxng_locales" title="searx.sxng_locales.sxng_locales"><code class="xref py py-obj docutils literal notranslate"><span class="pre">searx.sxng_locales.sxng_locales</span></code></a>).</p>
</dd></dl>

</section>


            <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 class="current">
<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 current"><a class="reference internal" href="index.html">Source-Code</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="searx.babel_extract.html">Custom message extractor (i18n)</a></li>
<li class="toctree-l2"><a class="reference internal" href="searx.botdetection.html">Bot Detection</a></li>
<li class="toctree-l2"><a class="reference internal" href="searx.exceptions.html">SearXNG Exceptions</a></li>
<li class="toctree-l2"><a class="reference internal" href="searx.favicons.html">Favicons (source)</a></li>
<li class="toctree-l2"><a class="reference internal" href="searx.infopage.html">Online <code class="docutils literal notranslate"><span class="pre">/info</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="searx.locales.html">Locales</a></li>
<li class="toctree-l2"><a class="reference internal" href="searx.plugins.hostnames.html">Hostnames plugin</a></li>
<li class="toctree-l2"><a class="reference internal" href="searx.plugins.tor_check.html">Tor check plugin</a></li>
<li class="toctree-l2"><a class="reference internal" href="searx.plugins.unit_converter.html">Unit converter plugin</a></li>
<li class="toctree-l2"><a class="reference internal" href="searx.redisdb.html">Redis DB</a></li>
<li class="toctree-l2"><a class="reference internal" href="searx.redislib.html">Redis Library</a></li>
<li class="toctree-l2"><a class="reference internal" href="searx.search.html">Search</a></li>
<li class="toctree-l2"><a class="reference internal" href="searx.search.processors.html">Search processors</a></li>
<li class="toctree-l2"><a class="reference internal" href="searx.settings.html">Settings Loader</a></li>
<li class="toctree-l2"><a class="reference internal" href="searx.sqlitedb.html">SQLite DB</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Utility functions for the engines</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#searx.utils.convert_str_to_int"><code class="docutils literal notranslate"><span class="pre">convert_str_to_int()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#searx.utils.detect_language"><code class="docutils literal notranslate"><span class="pre">detect_language()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#searx.utils.dict_subset"><code class="docutils literal notranslate"><span class="pre">dict_subset()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#searx.utils.ecma_unescape"><code class="docutils literal notranslate"><span class="pre">ecma_unescape()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#searx.utils.eval_xpath"><code class="docutils literal notranslate"><span class="pre">eval_xpath()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#searx.utils.eval_xpath_getindex"><code class="docutils literal notranslate"><span class="pre">eval_xpath_getindex()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#searx.utils.eval_xpath_list"><code class="docutils literal notranslate"><span class="pre">eval_xpath_list()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#searx.utils.extr"><code class="docutils literal notranslate"><span class="pre">extr()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#searx.utils.extract_text"><code class="docutils literal notranslate"><span class="pre">extract_text()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#searx.utils.extract_url"><code class="docutils literal notranslate"><span class="pre">extract_url()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#searx.utils.gen_useragent"><code class="docutils literal notranslate"><span class="pre">gen_useragent()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#searx.utils.get_embeded_stream_url"><code class="docutils literal notranslate"><span class="pre">get_embeded_stream_url()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#searx.utils.get_engine_from_settings"><code class="docutils literal notranslate"><span class="pre">get_engine_from_settings()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#searx.utils.get_xpath"><code class="docutils literal notranslate"><span class="pre">get_xpath()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#searx.utils.html_to_text"><code class="docutils literal notranslate"><span class="pre">html_to_text()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#searx.utils.humanize_bytes"><code class="docutils literal notranslate"><span class="pre">humanize_bytes()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#searx.utils.humanize_number"><code class="docutils literal notranslate"><span class="pre">humanize_number()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#searx.utils.int_or_zero"><code class="docutils literal notranslate"><span class="pre">int_or_zero()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#searx.utils.is_valid_lang"><code class="docutils literal notranslate"><span class="pre">is_valid_lang()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#searx.utils.js_variable_to_python"><code class="docutils literal notranslate"><span class="pre">js_variable_to_python()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#searx.utils.markdown_to_text"><code class="docutils literal notranslate"><span class="pre">markdown_to_text()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#searx.utils.normalize_url"><code class="docutils literal notranslate"><span class="pre">normalize_url()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#searx.utils.searx_useragent"><code class="docutils literal notranslate"><span class="pre">searx_useragent()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#searx.utils.to_string"><code class="docutils literal notranslate"><span class="pre">to_string()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#searx.utils.SEARCH_LANGUAGE_CODES"><code class="docutils literal notranslate"><span class="pre">SEARCH_LANGUAGE_CODES</span></code></a></li>
</ul>
</li>
</ul>
</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">Source-Code</a>
        <ul>
          <li>Previous: <a href="searx.sqlitedb.html" title="previous chapter">SQLite DB</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 role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../_sources/src/searx.utils.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="footer" role="contentinfo">
    &#169; Copyright SearXNG team.
    </div>
  </body>
</html>