[doc] build from commit 2287a6826a
This commit is contained in:
274
src/index.html
Normal file
274
src/index.html
Normal file
@@ -0,0 +1,274 @@
|
||||
<!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>Source-Code — SearXNG Documentation (2025.4.11+2287a6826)</title>
|
||||
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=6625fa76" />
|
||||
<link rel="stylesheet" type="text/css" href="../_static/searxng.css?v=52e4ff28" />
|
||||
<script src="../_static/documentation_options.js?v=725693a2"></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.4.11+2287a6826" 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="next" title="Custom message extractor (i18n)" href="searx.babel_extract.html" />
|
||||
<link rel="prev" title="utils/lxc.sh" href="../utils/lxc.sh.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.babel_extract.html" title="Custom message extractor (i18n)"
|
||||
accesskey="N">next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="../utils/lxc.sh.html" title="utils/lxc.sh"
|
||||
accesskey="P">previous</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../index.html">SearXNG Documentation (2025.4.11+2287a6826)</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">Source-Code</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<section id="source-code">
|
||||
<h1>Source-Code<a class="headerlink" href="#source-code" title="Link to this heading">¶</a></h1>
|
||||
<p>This is a partial documentation of our source code. We are not aiming to
|
||||
document every item from the source code, but we will add documentation when
|
||||
requested.</p>
|
||||
<div class="toctree-wrapper compound">
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="searx.babel_extract.html">Custom message extractor (i18n)</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.babel_extract.html#searx.babel_extract.extract"><code class="docutils literal notranslate"><span class="pre">extract()</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="searx.botdetection.html">Bot Detection</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.botdetection.html#searx.botdetection.get_network"><code class="docutils literal notranslate"><span class="pre">get_network()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.botdetection.html#searx.botdetection.get_real_ip"><code class="docutils literal notranslate"><span class="pre">get_real_ip()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.botdetection.html#searx.botdetection.too_many_requests"><code class="docutils literal notranslate"><span class="pre">too_many_requests()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.botdetection.html#module-searx.botdetection.ip_lists">IP lists</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.botdetection.html#module-searx.botdetection.ip_limit">Rate limit</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.botdetection.html#module-searx.botdetection.http_accept">Probe HTTP headers</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.botdetection.html#module-searx.botdetection.config">Config</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="searx.exceptions.html">SearXNG Exceptions</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.exceptions.html#searx.exceptions.SearxException"><code class="docutils literal notranslate"><span class="pre">SearxException</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.exceptions.html#searx.exceptions.SearxParameterException"><code class="docutils literal notranslate"><span class="pre">SearxParameterException</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.exceptions.html#searx.exceptions.SearxSettingsException"><code class="docutils literal notranslate"><span class="pre">SearxSettingsException</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.exceptions.html#searx.exceptions.SearxEngineException"><code class="docutils literal notranslate"><span class="pre">SearxEngineException</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.exceptions.html#searx.exceptions.SearxXPathSyntaxException"><code class="docutils literal notranslate"><span class="pre">SearxXPathSyntaxException</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.exceptions.html#searx.exceptions.SearxEngineResponseException"><code class="docutils literal notranslate"><span class="pre">SearxEngineResponseException</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.exceptions.html#searx.exceptions.SearxEngineAPIException"><code class="docutils literal notranslate"><span class="pre">SearxEngineAPIException</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.exceptions.html#searx.exceptions.SearxEngineAccessDeniedException"><code class="docutils literal notranslate"><span class="pre">SearxEngineAccessDeniedException</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.exceptions.html#searx.exceptions.SearxEngineCaptchaException"><code class="docutils literal notranslate"><span class="pre">SearxEngineCaptchaException</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.exceptions.html#searx.exceptions.SearxEngineTooManyRequestsException"><code class="docutils literal notranslate"><span class="pre">SearxEngineTooManyRequestsException</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.exceptions.html#searx.exceptions.SearxEngineXPathException"><code class="docutils literal notranslate"><span class="pre">SearxEngineXPathException</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="searx.favicons.html">Favicons (source)</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.favicons.html#searx.favicons.favicon_url"><code class="docutils literal notranslate"><span class="pre">favicon_url()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.favicons.html#searx.favicons.favicon_proxy"><code class="docutils literal notranslate"><span class="pre">favicon_proxy()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.favicons.html#module-searx.favicons.config">Favicons Config</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.favicons.html#module-searx.favicons.proxy">Favicons Proxy</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.favicons.html#module-searx.favicons.resolvers">Favicons Resolver</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.favicons.html#module-searx.favicons.cache">Favicons Cache</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="searx.infopage.html">Online <code class="docutils literal notranslate"><span class="pre">/info</span></code></a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.infopage.html#searx.infopage.InfoPage"><code class="docutils literal notranslate"><span class="pre">InfoPage</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.infopage.html#searx.infopage.InfoPageSet"><code class="docutils literal notranslate"><span class="pre">InfoPageSet</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="searx.locales.html">Locales</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.locales.html#searxngs-locale-data">SearXNG’s locale data</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.locales.html#module-searx.sxng_locales">SearXNG’s locale codes</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.locales.html#searxngs-locale-implementations">SearXNG’s locale implementations</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.locales.html#searx.locales.LOCALE_NAMES"><code class="docutils literal notranslate"><span class="pre">LOCALE_NAMES</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.locales.html#searx.locales.RTL_LOCALES"><code class="docutils literal notranslate"><span class="pre">RTL_LOCALES</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.locales.html#searx.locales.ADDITIONAL_TRANSLATIONS"><code class="docutils literal notranslate"><span class="pre">ADDITIONAL_TRANSLATIONS</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.locales.html#searx.locales.LOCALE_BEST_MATCH"><code class="docutils literal notranslate"><span class="pre">LOCALE_BEST_MATCH</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.locales.html#searx.locales.get_translations"><code class="docutils literal notranslate"><span class="pre">get_translations()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.locales.html#searx.locales.get_translation_locales"><code class="docutils literal notranslate"><span class="pre">get_translation_locales()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.locales.html#searx.locales.locales_initialize"><code class="docutils literal notranslate"><span class="pre">locales_initialize()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.locales.html#searx.locales.region_tag"><code class="docutils literal notranslate"><span class="pre">region_tag()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.locales.html#searx.locales.language_tag"><code class="docutils literal notranslate"><span class="pre">language_tag()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.locales.html#searx.locales.get_locale"><code class="docutils literal notranslate"><span class="pre">get_locale()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.locales.html#searx.locales.get_official_locales"><code class="docutils literal notranslate"><span class="pre">get_official_locales()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.locales.html#searx.locales.get_engine_locale"><code class="docutils literal notranslate"><span class="pre">get_engine_locale()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.locales.html#searx.locales.match_locale"><code class="docutils literal notranslate"><span class="pre">match_locale()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.locales.html#searx.locales.build_engine_locales"><code class="docutils literal notranslate"><span class="pre">build_engine_locales()</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="searx.redisdb.html">Redis DB</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.redisdb.html#searx.redisdb.OLD_REDIS_URL_DEFAULT_URL"><code class="docutils literal notranslate"><span class="pre">OLD_REDIS_URL_DEFAULT_URL</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="searx.redislib.html">Redis Library</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.redislib.html#searx.redislib.LUA_SCRIPT_STORAGE"><code class="docutils literal notranslate"><span class="pre">LUA_SCRIPT_STORAGE</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.redislib.html#searx.redislib.lua_script_storage"><code class="docutils literal notranslate"><span class="pre">lua_script_storage()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.redislib.html#searx.redislib.purge_by_prefix"><code class="docutils literal notranslate"><span class="pre">purge_by_prefix()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.redislib.html#searx.redislib.secret_hash"><code class="docutils literal notranslate"><span class="pre">secret_hash()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.redislib.html#searx.redislib.incr_counter"><code class="docutils literal notranslate"><span class="pre">incr_counter()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.redislib.html#searx.redislib.drop_counter"><code class="docutils literal notranslate"><span class="pre">drop_counter()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.redislib.html#searx.redislib.incr_sliding_window"><code class="docutils literal notranslate"><span class="pre">incr_sliding_window()</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="searx.search.html">Search</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.search.html#searx.search.EngineRef"><code class="docutils literal notranslate"><span class="pre">EngineRef</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.search.html#searx.search.SearchQuery"><code class="docutils literal notranslate"><span class="pre">SearchQuery</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.search.html#searx.search.Search"><code class="docutils literal notranslate"><span class="pre">Search</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.search.html#searx.search.SearchWithPlugins"><code class="docutils literal notranslate"><span class="pre">SearchWithPlugins</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="searx.search.processors.html">Search processors</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.search.processors.html#module-searx.search.processors.abstract">Abstract processor class</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.search.processors.html#module-searx.search.processors.offline">Offline processor</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.search.processors.html#module-searx.search.processors.online">Online processor</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.search.processors.html#module-searx.search.processors.online_currency">Online currency processor</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.search.processors.html#module-searx.search.processors.online_dictionary">Online dictionary processor</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.search.processors.html#module-searx.search.processors.online_url_search">Online URL search processor</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="searx.settings.html">Settings Loader</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.settings.html#searx.settings_loader.DEFAULT_SETTINGS_FILE"><code class="docutils literal notranslate"><span class="pre">DEFAULT_SETTINGS_FILE</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.settings.html#searx.settings_loader.load_yaml"><code class="docutils literal notranslate"><span class="pre">load_yaml()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.settings.html#searx.settings_loader.get_yaml_cfg"><code class="docutils literal notranslate"><span class="pre">get_yaml_cfg()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.settings.html#searx.settings_loader.get_user_cfg_folder"><code class="docutils literal notranslate"><span class="pre">get_user_cfg_folder()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.settings.html#searx.settings_loader.load_settings"><code class="docutils literal notranslate"><span class="pre">load_settings()</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="searx.sqlitedb.html">SQLite DB</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.sqlitedb.html#searx.sqlitedb.SQLiteAppl"><code class="docutils literal notranslate"><span class="pre">SQLiteAppl</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.sqlitedb.html#searx.sqlitedb.SQLiteProperties"><code class="docutils literal notranslate"><span class="pre">SQLiteProperties</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="searx.utils.html">Utility functions for the engines</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.utils.html#searx.utils.SEARCH_LANGUAGE_CODES"><code class="docutils literal notranslate"><span class="pre">SEARCH_LANGUAGE_CODES</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.utils.html#searx.utils.searx_useragent"><code class="docutils literal notranslate"><span class="pre">searx_useragent()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.utils.html#searx.utils.gen_useragent"><code class="docutils literal notranslate"><span class="pre">gen_useragent()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.utils.html#searx.utils.html_to_text"><code class="docutils literal notranslate"><span class="pre">html_to_text()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.utils.html#searx.utils.markdown_to_text"><code class="docutils literal notranslate"><span class="pre">markdown_to_text()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.utils.html#searx.utils.extract_text"><code class="docutils literal notranslate"><span class="pre">extract_text()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.utils.html#searx.utils.normalize_url"><code class="docutils literal notranslate"><span class="pre">normalize_url()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.utils.html#searx.utils.extract_url"><code class="docutils literal notranslate"><span class="pre">extract_url()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.utils.html#searx.utils.dict_subset"><code class="docutils literal notranslate"><span class="pre">dict_subset()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.utils.html#searx.utils.humanize_bytes"><code class="docutils literal notranslate"><span class="pre">humanize_bytes()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.utils.html#searx.utils.humanize_number"><code class="docutils literal notranslate"><span class="pre">humanize_number()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.utils.html#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-l2"><a class="reference internal" href="searx.utils.html#searx.utils.extr"><code class="docutils literal notranslate"><span class="pre">extr()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.utils.html#searx.utils.int_or_zero"><code class="docutils literal notranslate"><span class="pre">int_or_zero()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.utils.html#searx.utils.is_valid_lang"><code class="docutils literal notranslate"><span class="pre">is_valid_lang()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.utils.html#searx.utils.to_string"><code class="docutils literal notranslate"><span class="pre">to_string()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.utils.html#searx.utils.ecma_unescape"><code class="docutils literal notranslate"><span class="pre">ecma_unescape()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.utils.html#searx.utils.remove_pua_from_str"><code class="docutils literal notranslate"><span class="pre">remove_pua_from_str()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.utils.html#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-l2"><a class="reference internal" href="searx.utils.html#searx.utils.get_xpath"><code class="docutils literal notranslate"><span class="pre">get_xpath()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.utils.html#searx.utils.eval_xpath"><code class="docutils literal notranslate"><span class="pre">eval_xpath()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.utils.html#searx.utils.eval_xpath_list"><code class="docutils literal notranslate"><span class="pre">eval_xpath_list()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.utils.html#searx.utils.eval_xpath_getindex"><code class="docutils literal notranslate"><span class="pre">eval_xpath_getindex()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.utils.html#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-l2"><a class="reference internal" href="searx.utils.html#searx.utils.detect_language"><code class="docutils literal notranslate"><span class="pre">detect_language()</span></code></a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.utils.html#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-l2"><a class="reference internal" href="searx.utils.html#searx.utils.parse_duration_string"><code class="docutils literal notranslate"><span class="pre">parse_duration_string()</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</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="current reference internal" href="#">Source-Code</a><ul>
|
||||
<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.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"><a class="reference internal" href="searx.utils.html">Utility functions for the engines</a></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>Previous: <a href="../utils/lxc.sh.html" title="previous chapter"><code class="docutils literal notranslate"><span class="pre">utils/lxc.sh</span></code></a>
|
||||
<li>Next: <a href="searx.babel_extract.html" title="next chapter">Custom message extractor (i18n)</a>
|
||||
</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/index.rst.txt"
|
||||
rel="nofollow">Show Source</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright SearXNG team.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
163
src/searx.babel_extract.html
Normal file
163
src/searx.babel_extract.html
Normal file
@@ -0,0 +1,163 @@
|
||||
<!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>Custom message extractor (i18n) — SearXNG Documentation (2025.4.11+2287a6826)</title>
|
||||
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=6625fa76" />
|
||||
<link rel="stylesheet" type="text/css" href="../_static/searxng.css?v=52e4ff28" />
|
||||
<script src="../_static/documentation_options.js?v=725693a2"></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.4.11+2287a6826" 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="next" title="Bot Detection" href="searx.botdetection.html" />
|
||||
<link rel="prev" title="Source-Code" href="index.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.botdetection.html" title="Bot Detection"
|
||||
accesskey="N">next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="index.html" title="Source-Code"
|
||||
accesskey="P">previous</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../index.html">SearXNG Documentation (2025.4.11+2287a6826)</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Source-Code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">Custom message extractor (i18n)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<section id="module-searx.babel_extract">
|
||||
<span id="custom-message-extractor-i18n"></span><span id="searx-babel-extract"></span><h1>Custom message extractor (i18n)<a class="headerlink" href="#module-searx.babel_extract" title="Link to this heading">¶</a></h1>
|
||||
<p>This module implements the <a class="extlink-origin reference external" href="https://github.com/searxng/searxng/blob/master/babel.cfg">searxng_msg</a> extractor to
|
||||
extract messages from:</p>
|
||||
<ul class="simple">
|
||||
<li><p><a class="extlink-origin reference external" href="https://github.com/searxng/searxng/blob/master/searx/searxng.msg">git://searx/searxng.msg</a></p></li>
|
||||
</ul>
|
||||
<p>The <code class="docutils literal notranslate"><span class="pre">searxng.msg</span></code> files are selected by <a class="reference external" href="https://babel.pocoo.org/en/latest/index.html">Babel</a>, see Babel’s configuration in
|
||||
<a class="extlink-origin reference external" href="https://github.com/searxng/searxng/blob/master/babel.cfg">git://babel.cfg</a>:</p>
|
||||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">searxng_msg</span> <span class="o">=</span> <span class="n">searx</span><span class="o">.</span><span class="n">babel_extract</span><span class="o">.</span><span class="n">extract</span>
|
||||
<span class="o">...</span>
|
||||
<span class="p">[</span><span class="n">searxng_msg</span><span class="p">:</span> <span class="o">**/</span><span class="n">searxng</span><span class="o">.</span><span class="n">msg</span><span class="p">]</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>A <code class="docutils literal notranslate"><span class="pre">searxng.msg</span></code> file is a python file that is <em>executed</em> by the
|
||||
<a class="reference internal" href="#searx.babel_extract.extract" title="searx.babel_extract.extract"><code class="xref py py-obj docutils literal notranslate"><span class="pre">extract</span></code></a> function. Additional <code class="docutils literal notranslate"><span class="pre">searxng.msg</span></code> files can be added by:</p>
|
||||
<ol class="arabic simple">
|
||||
<li><p>Adding a <code class="docutils literal notranslate"><span class="pre">searxng.msg</span></code> file in one of the SearXNG python packages and</p></li>
|
||||
<li><p>implement a method in <a class="reference internal" href="#searx.babel_extract.extract" title="searx.babel_extract.extract"><code class="xref py py-obj docutils literal notranslate"><span class="pre">extract</span></code></a> that yields messages from this file.</p></li>
|
||||
</ol>
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.babel_extract.extract">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.babel_extract.</span></span><span class="sig-name descname"><span class="pre">extract</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fileobj</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">keywords</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">comment_tags</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">options</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/babel_extract.html#extract"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.babel_extract.extract" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Extract messages from <code class="docutils literal notranslate"><span class="pre">searxng.msg</span></code> files by a custom <a class="reference external" href="https://babel.pocoo.org/en/latest/messages.html#writing-extraction-methods">extractor</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 current"><a class="current reference internal" href="#">Custom message extractor (i18n)</a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.babel_extract.extract"><code class="docutils literal notranslate"><span class="pre">extract()</span></code></a></li>
|
||||
</ul>
|
||||
</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.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"><a class="reference internal" href="searx.utils.html">Utility functions for the engines</a></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="index.html" title="previous chapter">Source-Code</a>
|
||||
<li>Next: <a href="searx.botdetection.html" title="next chapter">Bot Detection</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.babel_extract.rst.txt"
|
||||
rel="nofollow">Show Source</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright SearXNG team.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
579
src/searx.botdetection.html
Normal file
579
src/searx.botdetection.html
Normal file
@@ -0,0 +1,579 @@
|
||||
<!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>Bot Detection — SearXNG Documentation (2025.4.11+2287a6826)</title>
|
||||
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=6625fa76" />
|
||||
<link rel="stylesheet" type="text/css" href="../_static/searxng.css?v=52e4ff28" />
|
||||
<script src="../_static/documentation_options.js?v=725693a2"></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.4.11+2287a6826" 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="next" title="SearXNG Exceptions" href="searx.exceptions.html" />
|
||||
<link rel="prev" title="Custom message extractor (i18n)" href="searx.babel_extract.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.exceptions.html" title="SearXNG Exceptions"
|
||||
accesskey="N">next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="searx.babel_extract.html" title="Custom message extractor (i18n)"
|
||||
accesskey="P">previous</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../index.html">SearXNG Documentation (2025.4.11+2287a6826)</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Source-Code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">Bot Detection</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<section id="bot-detection">
|
||||
<span id="botdetection"></span><h1>Bot Detection<a class="headerlink" href="#bot-detection" title="Link to this heading">¶</a></h1>
|
||||
<nav class="contents local" id="contents">
|
||||
<ul class="simple">
|
||||
<li><p><a class="reference internal" href="#module-searx.botdetection.ip_lists" id="id4">IP lists</a></p>
|
||||
<ul>
|
||||
<li><p><a class="reference internal" href="#method-ip-lists" id="id5">Method <code class="docutils literal notranslate"><span class="pre">ip_lists</span></code></a></p></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><p><a class="reference internal" href="#module-searx.botdetection.ip_limit" id="id6">Rate limit</a></p>
|
||||
<ul>
|
||||
<li><p><a class="reference internal" href="#method-ip-limit" id="id7">Method <code class="docutils literal notranslate"><span class="pre">ip_limit</span></code></a></p></li>
|
||||
<li><p><a class="reference internal" href="#method-link-token" id="id8">Method <code class="docutils literal notranslate"><span class="pre">link_token</span></code></a></p></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><p><a class="reference internal" href="#module-searx.botdetection.http_accept" id="id9">Probe HTTP headers</a></p>
|
||||
<ul>
|
||||
<li><p><a class="reference internal" href="#method-http-accept" id="id10">Method <code class="docutils literal notranslate"><span class="pre">http_accept</span></code></a></p></li>
|
||||
<li><p><a class="reference internal" href="#method-http-accept-encoding" id="id11">Method <code class="docutils literal notranslate"><span class="pre">http_accept_encoding</span></code></a></p></li>
|
||||
<li><p><a class="reference internal" href="#method-http-accept-language" id="id12">Method <code class="docutils literal notranslate"><span class="pre">http_accept_language</span></code></a></p></li>
|
||||
<li><p><a class="reference internal" href="#method-http-connection" id="id13">Method <code class="docutils literal notranslate"><span class="pre">http_connection</span></code></a></p></li>
|
||||
<li><p><a class="reference internal" href="#method-http-user-agent" id="id14">Method <code class="docutils literal notranslate"><span class="pre">http_user_agent</span></code></a></p></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><p><a class="reference internal" href="#module-searx.botdetection.config" id="id15">Config</a></p></li>
|
||||
</ul>
|
||||
</nav>
|
||||
<p id="botdetection-src"><span id="module-searx.botdetection"></span>Implementations used for bot detection.</p>
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.botdetection.get_network">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.botdetection.</span></span><span class="sig-name descname"><span class="pre">get_network</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">real_ip</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/ipaddress.html#ipaddress.IPv4Address" title="(in Python v3.13)"><span class="pre">IPv4Address</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/ipaddress.html#ipaddress.IPv6Address" title="(in Python v3.13)"><span class="pre">IPv6Address</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">cfg</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="#searx.botdetection.config.Config" title="searx.botdetection.config.Config"><span class="pre">Config</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/ipaddress.html#ipaddress.IPv4Network" title="(in Python v3.13)"><span class="pre">IPv4Network</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/ipaddress.html#ipaddress.IPv6Network" title="(in Python v3.13)"><span class="pre">IPv6Network</span></a></span></span><a class="reference internal" href="../_modules/searx/botdetection/_helpers.html#get_network"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.botdetection.get_network" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Returns the (client) network of whether the real_ip is part of.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.botdetection.get_real_ip">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.botdetection.</span></span><span class="sig-name descname"><span class="pre">get_real_ip</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">request</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="../dev/extended_types.html#searx.extended_types.SXNG_Request" title="searx.extended_types.SXNG_Request"><span class="pre">SXNG_Request</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</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/botdetection/_helpers.html#get_real_ip"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.botdetection.get_real_ip" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Returns real IP of the request. Since not all proxies set all the HTTP
|
||||
headers and incoming headers can be faked it may happen that the IP cannot
|
||||
be determined correctly.</p>
|
||||
<aside class="sidebar">
|
||||
<p class="sidebar-title"><a class="reference external" href="https://flask.palletsprojects.com/en/stable/api/#flask.Request.remote_addr" title="(in Flask v3.1.x)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">flask.Request.remote_addr</span></code></a></p>
|
||||
<p>SearXNG uses Werkzeug’s <a class="reference external" href="https://werkzeug.palletsprojects.com/middleware/proxy_fix/">ProxyFix</a> (with it default <code class="docutils literal notranslate"><span class="pre">x_for=1</span></code>).</p>
|
||||
</aside>
|
||||
<p>This function tries to get the remote IP in the order listed below,
|
||||
additional some tests are done and if inconsistencies or errors are
|
||||
detected, they are logged.</p>
|
||||
<p>The remote IP of the request is taken from (first match):</p>
|
||||
<ul class="simple">
|
||||
<li><p><a class="reference external" href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For">X-Forwarded-For</a> header</p></li>
|
||||
<li><p><a class="reference external" href="https://github.com/searxng/searxng/issues/1237#issuecomment-1147564516">X-real-IP header</a></p></li>
|
||||
<li><p><a class="reference external" href="https://flask.palletsprojects.com/en/stable/api/#flask.Request.remote_addr" title="(in Flask v3.1.x)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">flask.Request.remote_addr</span></code></a></p></li>
|
||||
</ul>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.botdetection.too_many_requests">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.botdetection.</span></span><span class="sig-name descname"><span class="pre">too_many_requests</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">network</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/ipaddress.html#ipaddress.IPv4Network" title="(in Python v3.13)"><span class="pre">IPv4Network</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/ipaddress.html#ipaddress.IPv6Network" title="(in Python v3.13)"><span class="pre">IPv6Network</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">log_msg</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">→</span> <span class="sig-return-typehint"><a class="reference external" href="https://werkzeug.palletsprojects.com/en/stable/wrappers/#werkzeug.wrappers.Response" title="(in Werkzeug v3.1.x)"><span class="pre">Response</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/botdetection/_helpers.html#too_many_requests"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.botdetection.too_many_requests" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Returns a HTTP 429 response object and writes a ERROR message to the
|
||||
‘botdetection’ logger. This function is used in part by the filter methods
|
||||
to return the default <code class="docutils literal notranslate"><span class="pre">Too</span> <span class="pre">Many</span> <span class="pre">Requests</span></code> response.</p>
|
||||
</dd></dl>
|
||||
|
||||
<section id="module-searx.botdetection.ip_lists">
|
||||
<span id="ip-lists"></span><span id="botdetection-ip-lists"></span><h2><a class="toc-backref" href="#id4" role="doc-backlink">IP lists</a><a class="headerlink" href="#module-searx.botdetection.ip_lists" title="Link to this heading">¶</a></h2>
|
||||
<section id="method-ip-lists">
|
||||
<span id="id1"></span><h3><a class="toc-backref" href="#id5" role="doc-backlink">Method <code class="docutils literal notranslate"><span class="pre">ip_lists</span></code></a><a class="headerlink" href="#method-ip-lists" title="Link to this heading">¶</a></h3>
|
||||
<p>The <code class="docutils literal notranslate"><span class="pre">ip_lists</span></code> method implements IP <a class="reference internal" href="#searx.botdetection.ip_lists.block_ip" title="searx.botdetection.ip_lists.block_ip"><code class="xref py py-obj docutils literal notranslate"><span class="pre">block-</span></code></a> and
|
||||
<a class="reference internal" href="#searx.botdetection.ip_lists.pass_ip" title="searx.botdetection.ip_lists.pass_ip"><code class="xref py py-obj docutils literal notranslate"><span class="pre">pass-lists</span></code></a>.</p>
|
||||
<div class="highlight-toml notranslate"><div class="highlight"><pre><span></span><span class="k">[botdetection.ip_lists]</span>
|
||||
|
||||
<span class="n">pass_ip</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span>
|
||||
<span class="w"> </span><span class="s1">'167.235.158.251'</span><span class="p">,</span><span class="w"> </span><span class="c1"># IPv4 of check.searx.space</span>
|
||||
<span class="w"> </span><span class="s1">'192.168.0.0/16'</span><span class="p">,</span><span class="w"> </span><span class="c1"># IPv4 private network</span>
|
||||
<span class="w"> </span><span class="s1">'fe80::/10'</span><span class="w"> </span><span class="c1"># IPv6 linklocal</span>
|
||||
<span class="p">]</span>
|
||||
<span class="n">block_ip</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span>
|
||||
<span class="w"> </span><span class="s1">'93.184.216.34'</span><span class="p">,</span><span class="w"> </span><span class="c1"># IPv4 of example.org</span>
|
||||
<span class="w"> </span><span class="s1">'257.1.1.1'</span><span class="p">,</span><span class="w"> </span><span class="c1"># invalid IP --> will be ignored, logged in ERROR class</span>
|
||||
<span class="p">]</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</section>
|
||||
<dl class="py data">
|
||||
<dt class="sig sig-object py" id="searx.botdetection.ip_lists.SEARXNG_ORG">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.botdetection.ip_lists.</span></span><span class="sig-name descname"><span class="pre">SEARXNG_ORG</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">['167.235.158.251',</span> <span class="pre">'2a01:04f8:1c1c:8fc2::/64']</span></em><a class="headerlink" href="#searx.botdetection.ip_lists.SEARXNG_ORG" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Passlist of IPs from the SearXNG organization, e.g. <cite>check.searx.space</cite>.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.botdetection.ip_lists.pass_ip">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.botdetection.ip_lists.</span></span><span class="sig-name descname"><span class="pre">pass_ip</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">real_ip</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/ipaddress.html#ipaddress.IPv4Address" title="(in Python v3.13)"><span class="pre">IPv4Address</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/ipaddress.html#ipaddress.IPv6Address" title="(in Python v3.13)"><span class="pre">IPv6Address</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">cfg</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="#searx.botdetection.config.Config" title="searx.botdetection.config.Config"><span class="pre">Config</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</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></span><a class="reference internal" href="../_modules/searx/botdetection/ip_lists.html#pass_ip"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.botdetection.ip_lists.pass_ip" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Checks if the IP on the subnet is in one of the members of the
|
||||
<code class="docutils literal notranslate"><span class="pre">botdetection.ip_lists.pass_ip</span></code> list.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.botdetection.ip_lists.block_ip">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.botdetection.ip_lists.</span></span><span class="sig-name descname"><span class="pre">block_ip</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">real_ip</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/ipaddress.html#ipaddress.IPv4Address" title="(in Python v3.13)"><span class="pre">IPv4Address</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/ipaddress.html#ipaddress.IPv6Address" title="(in Python v3.13)"><span class="pre">IPv6Address</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">cfg</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="#searx.botdetection.config.Config" title="searx.botdetection.config.Config"><span class="pre">Config</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</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></span><a class="reference internal" href="../_modules/searx/botdetection/ip_lists.html#block_ip"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.botdetection.ip_lists.block_ip" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Checks if the IP on the subnet is in one of the members of the
|
||||
<code class="docutils literal notranslate"><span class="pre">botdetection.ip_lists.block_ip</span></code> list.</p>
|
||||
</dd></dl>
|
||||
|
||||
</section>
|
||||
<section id="module-searx.botdetection.ip_limit">
|
||||
<span id="rate-limit"></span><span id="botdetection-rate-limit"></span><h2><a class="toc-backref" href="#id6" role="doc-backlink">Rate limit</a><a class="headerlink" href="#module-searx.botdetection.ip_limit" title="Link to this heading">¶</a></h2>
|
||||
<section id="method-ip-limit">
|
||||
<span id="botdetection-ip-limit"></span><h3><a class="toc-backref" href="#id7" role="doc-backlink">Method <code class="docutils literal notranslate"><span class="pre">ip_limit</span></code></a><a class="headerlink" href="#method-ip-limit" title="Link to this heading">¶</a></h3>
|
||||
<p>The <code class="docutils literal notranslate"><span class="pre">ip_limit</span></code> method counts request from an IP in <em>sliding windows</em>. If
|
||||
there are to many requests in a sliding window, the request is evaluated as a
|
||||
bot request. This method requires a redis DB and needs a HTTP <a class="reference external" href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For">X-Forwarded-For</a>
|
||||
header. To take privacy only the hash value of an IP is stored in the redis DB
|
||||
and at least for a maximum of 10 minutes.</p>
|
||||
<p>The <a class="reference internal" href="#module-searx.botdetection.link_token" title="searx.botdetection.link_token"><code class="xref py py-obj docutils literal notranslate"><span class="pre">link_token</span></code></a> method can be used to investigate whether a request is
|
||||
<em>suspicious</em>. To activate the <a class="reference internal" href="#module-searx.botdetection.link_token" title="searx.botdetection.link_token"><code class="xref py py-obj docutils literal notranslate"><span class="pre">link_token</span></code></a> method in the
|
||||
<a class="reference internal" href="#module-searx.botdetection.ip_limit" title="searx.botdetection.ip_limit"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ip_limit</span></code></a> method add the following configuration:</p>
|
||||
<div class="highlight-toml notranslate"><div class="highlight"><pre><span></span><span class="k">[botdetection.ip_limit]</span>
|
||||
<span class="n">link_token</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>If the <a class="reference internal" href="#module-searx.botdetection.link_token" title="searx.botdetection.link_token"><code class="xref py py-obj docutils literal notranslate"><span class="pre">link_token</span></code></a> method is activated and a request is <em>suspicious</em>
|
||||
the request rates are reduced:</p>
|
||||
<ul class="simple">
|
||||
<li><p><a class="reference internal" href="#searx.botdetection.ip_limit.BURST_MAX" title="searx.botdetection.ip_limit.BURST_MAX"><code class="xref py py-obj docutils literal notranslate"><span class="pre">BURST_MAX</span></code></a> -> <a class="reference internal" href="#searx.botdetection.ip_limit.BURST_MAX_SUSPICIOUS" title="searx.botdetection.ip_limit.BURST_MAX_SUSPICIOUS"><code class="xref py py-obj docutils literal notranslate"><span class="pre">BURST_MAX_SUSPICIOUS</span></code></a></p></li>
|
||||
<li><p><a class="reference internal" href="#searx.botdetection.ip_limit.LONG_MAX" title="searx.botdetection.ip_limit.LONG_MAX"><code class="xref py py-obj docutils literal notranslate"><span class="pre">LONG_MAX</span></code></a> -> <a class="reference internal" href="#searx.botdetection.ip_limit.LONG_MAX_SUSPICIOUS" title="searx.botdetection.ip_limit.LONG_MAX_SUSPICIOUS"><code class="xref py py-obj docutils literal notranslate"><span class="pre">LONG_MAX_SUSPICIOUS</span></code></a></p></li>
|
||||
</ul>
|
||||
<p>To intercept bots that get their IPs from a range of IPs, there is a
|
||||
<a class="reference internal" href="#searx.botdetection.ip_limit.SUSPICIOUS_IP_WINDOW" title="searx.botdetection.ip_limit.SUSPICIOUS_IP_WINDOW"><code class="xref py py-obj docutils literal notranslate"><span class="pre">SUSPICIOUS_IP_WINDOW</span></code></a>. In this window the suspicious IPs are stored
|
||||
for a longer time. IPs stored in this sliding window have a maximum of
|
||||
<a class="reference internal" href="#searx.botdetection.ip_limit.SUSPICIOUS_IP_MAX" title="searx.botdetection.ip_limit.SUSPICIOUS_IP_MAX"><code class="xref py py-obj docutils literal notranslate"><span class="pre">SUSPICIOUS_IP_MAX</span></code></a> accesses before they are blocked. As soon as the IP
|
||||
makes a request that is not suspicious, the sliding window for this IP is
|
||||
dropped.</p>
|
||||
</section>
|
||||
<dl class="py data">
|
||||
<dt class="sig sig-object py" id="searx.botdetection.ip_limit.BURST_WINDOW">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.botdetection.ip_limit.</span></span><span class="sig-name descname"><span class="pre">BURST_WINDOW</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">20</span></em><a class="headerlink" href="#searx.botdetection.ip_limit.BURST_WINDOW" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Time (sec) before sliding window for <em>burst</em> requests expires.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py data">
|
||||
<dt class="sig sig-object py" id="searx.botdetection.ip_limit.BURST_MAX">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.botdetection.ip_limit.</span></span><span class="sig-name descname"><span class="pre">BURST_MAX</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">15</span></em><a class="headerlink" href="#searx.botdetection.ip_limit.BURST_MAX" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Maximum requests from one IP in the <a class="reference internal" href="#searx.botdetection.ip_limit.BURST_WINDOW" title="searx.botdetection.ip_limit.BURST_WINDOW"><code class="xref py py-obj docutils literal notranslate"><span class="pre">BURST_WINDOW</span></code></a></p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py data">
|
||||
<dt class="sig sig-object py" id="searx.botdetection.ip_limit.BURST_MAX_SUSPICIOUS">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.botdetection.ip_limit.</span></span><span class="sig-name descname"><span class="pre">BURST_MAX_SUSPICIOUS</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">2</span></em><a class="headerlink" href="#searx.botdetection.ip_limit.BURST_MAX_SUSPICIOUS" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Maximum of suspicious requests from one IP in the <a class="reference internal" href="#searx.botdetection.ip_limit.BURST_WINDOW" title="searx.botdetection.ip_limit.BURST_WINDOW"><code class="xref py py-obj docutils literal notranslate"><span class="pre">BURST_WINDOW</span></code></a></p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py data">
|
||||
<dt class="sig sig-object py" id="searx.botdetection.ip_limit.LONG_WINDOW">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.botdetection.ip_limit.</span></span><span class="sig-name descname"><span class="pre">LONG_WINDOW</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">600</span></em><a class="headerlink" href="#searx.botdetection.ip_limit.LONG_WINDOW" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Time (sec) before the longer sliding window expires.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py data">
|
||||
<dt class="sig sig-object py" id="searx.botdetection.ip_limit.LONG_MAX">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.botdetection.ip_limit.</span></span><span class="sig-name descname"><span class="pre">LONG_MAX</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">150</span></em><a class="headerlink" href="#searx.botdetection.ip_limit.LONG_MAX" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Maximum requests from one IP in the <a class="reference internal" href="#searx.botdetection.ip_limit.LONG_WINDOW" title="searx.botdetection.ip_limit.LONG_WINDOW"><code class="xref py py-obj docutils literal notranslate"><span class="pre">LONG_WINDOW</span></code></a></p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py data">
|
||||
<dt class="sig sig-object py" id="searx.botdetection.ip_limit.LONG_MAX_SUSPICIOUS">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.botdetection.ip_limit.</span></span><span class="sig-name descname"><span class="pre">LONG_MAX_SUSPICIOUS</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">10</span></em><a class="headerlink" href="#searx.botdetection.ip_limit.LONG_MAX_SUSPICIOUS" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Maximum suspicious requests from one IP in the <a class="reference internal" href="#searx.botdetection.ip_limit.LONG_WINDOW" title="searx.botdetection.ip_limit.LONG_WINDOW"><code class="xref py py-obj docutils literal notranslate"><span class="pre">LONG_WINDOW</span></code></a></p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py data">
|
||||
<dt class="sig sig-object py" id="searx.botdetection.ip_limit.API_WINDOW">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.botdetection.ip_limit.</span></span><span class="sig-name descname"><span class="pre">API_WINDOW</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">3600</span></em><a class="headerlink" href="#searx.botdetection.ip_limit.API_WINDOW" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Time (sec) before sliding window for API requests (format != html) expires.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py data">
|
||||
<dt class="sig sig-object py" id="searx.botdetection.ip_limit.API_MAX">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.botdetection.ip_limit.</span></span><span class="sig-name descname"><span class="pre">API_MAX</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">4</span></em><a class="headerlink" href="#searx.botdetection.ip_limit.API_MAX" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Maximum requests from one IP in the <a class="reference internal" href="#searx.botdetection.ip_limit.API_WINDOW" title="searx.botdetection.ip_limit.API_WINDOW"><code class="xref py py-obj docutils literal notranslate"><span class="pre">API_WINDOW</span></code></a></p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py data">
|
||||
<dt class="sig sig-object py" id="searx.botdetection.ip_limit.SUSPICIOUS_IP_WINDOW">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.botdetection.ip_limit.</span></span><span class="sig-name descname"><span class="pre">SUSPICIOUS_IP_WINDOW</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">2592000</span></em><a class="headerlink" href="#searx.botdetection.ip_limit.SUSPICIOUS_IP_WINDOW" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Time (sec) before sliding window for one suspicious IP expires.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py data">
|
||||
<dt class="sig sig-object py" id="searx.botdetection.ip_limit.SUSPICIOUS_IP_MAX">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.botdetection.ip_limit.</span></span><span class="sig-name descname"><span class="pre">SUSPICIOUS_IP_MAX</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">3</span></em><a class="headerlink" href="#searx.botdetection.ip_limit.SUSPICIOUS_IP_MAX" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Maximum requests from one suspicious IP in the <a class="reference internal" href="#searx.botdetection.ip_limit.SUSPICIOUS_IP_WINDOW" title="searx.botdetection.ip_limit.SUSPICIOUS_IP_WINDOW"><code class="xref py py-obj docutils literal notranslate"><span class="pre">SUSPICIOUS_IP_WINDOW</span></code></a>.</p>
|
||||
</dd></dl>
|
||||
|
||||
<section id="method-link-token">
|
||||
<span id="module-searx.botdetection.link_token"></span><h3><a class="toc-backref" href="#id8" role="doc-backlink">Method <code class="docutils literal notranslate"><span class="pre">link_token</span></code></a><a class="headerlink" href="#method-link-token" title="Link to this heading">¶</a></h3>
|
||||
<p>The <code class="docutils literal notranslate"><span class="pre">link_token</span></code> method evaluates a request as <a class="reference internal" href="#searx.botdetection.link_token.is_suspicious" title="searx.botdetection.link_token.is_suspicious"><code class="xref py py-obj docutils literal notranslate"><span class="pre">suspicious</span></code></a> if the URL <code class="docutils literal notranslate"><span class="pre">/client<token>.css</span></code> is not requested by the
|
||||
client. By adding a random component (the token) in the URL, a bot can not send
|
||||
a ping by request a static URL.</p>
|
||||
<div class="admonition note">
|
||||
<p class="admonition-title">Note</p>
|
||||
<p>This method requires a redis DB and needs a HTTP <a class="reference external" href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For">X-Forwarded-For</a> header.</p>
|
||||
</div>
|
||||
<p>To get in use of this method a flask URL route needs to be added:</p>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="nd">@app</span><span class="o">.</span><span class="n">route</span><span class="p">(</span><span class="s1">'/client<token>.css'</span><span class="p">,</span> <span class="n">methods</span><span class="o">=</span><span class="p">[</span><span class="s1">'GET'</span><span class="p">,</span> <span class="s1">'POST'</span><span class="p">])</span>
|
||||
<span class="k">def</span><span class="w"> </span><span class="nf">client_token</span><span class="p">(</span><span class="n">token</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="n">link_token</span><span class="o">.</span><span class="n">ping</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">token</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">Response</span><span class="p">(</span><span class="s1">''</span><span class="p">,</span> <span class="n">mimetype</span><span class="o">=</span><span class="s1">'text/css'</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>And in the HTML template from flask a stylesheet link is needed (the value of
|
||||
<code class="docutils literal notranslate"><span class="pre">link_token</span></code> comes from <a class="reference internal" href="#searx.botdetection.link_token.get_token" title="searx.botdetection.link_token.get_token"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_token</span></code></a>):</p>
|
||||
<div class="highlight-html notranslate"><div class="highlight"><pre><span></span><span class="p"><</span><span class="nt">link</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span>
|
||||
<span class="na">href</span><span class="o">=</span><span class="s">"{{ url_for('client_token', token=link_token) }}"</span>
|
||||
<span class="na">type</span><span class="o">=</span><span class="s">"text/css"</span> <span class="p">></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</section>
|
||||
<dl class="py data">
|
||||
<dt class="sig sig-object py" id="searx.botdetection.link_token.TOKEN_LIVE_TIME">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.botdetection.link_token.</span></span><span class="sig-name descname"><span class="pre">TOKEN_LIVE_TIME</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">600</span></em><a class="headerlink" href="#searx.botdetection.link_token.TOKEN_LIVE_TIME" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Lifetime (sec) of limiter’s CSS token.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py data">
|
||||
<dt class="sig sig-object py" id="searx.botdetection.link_token.PING_LIVE_TIME">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.botdetection.link_token.</span></span><span class="sig-name descname"><span class="pre">PING_LIVE_TIME</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">3600</span></em><a class="headerlink" href="#searx.botdetection.link_token.PING_LIVE_TIME" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Lifetime (sec) of the ping-key from a client (request)</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py data">
|
||||
<dt class="sig sig-object py" id="searx.botdetection.link_token.PING_KEY">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.botdetection.link_token.</span></span><span class="sig-name descname"><span class="pre">PING_KEY</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">'SearXNG_limiter.ping'</span></em><a class="headerlink" href="#searx.botdetection.link_token.PING_KEY" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Prefix of all ping-keys generated by <a class="reference internal" href="#searx.botdetection.link_token.get_ping_key" title="searx.botdetection.link_token.get_ping_key"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_ping_key</span></code></a></p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py data">
|
||||
<dt class="sig sig-object py" id="searx.botdetection.link_token.TOKEN_KEY">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.botdetection.link_token.</span></span><span class="sig-name descname"><span class="pre">TOKEN_KEY</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">'SearXNG_limiter.token'</span></em><a class="headerlink" href="#searx.botdetection.link_token.TOKEN_KEY" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Key for which the current token is stored in the DB</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.botdetection.link_token.is_suspicious">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.botdetection.link_token.</span></span><span class="sig-name descname"><span class="pre">is_suspicious</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">network</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/ipaddress.html#ipaddress.IPv4Network" title="(in Python v3.13)"><span class="pre">IPv4Network</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/ipaddress.html#ipaddress.IPv6Network" title="(in Python v3.13)"><span class="pre">IPv6Network</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">request</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="../dev/extended_types.html#searx.extended_types.SXNG_Request" title="searx.extended_types.SXNG_Request"><span class="pre">SXNG_Request</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">renew</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><a class="reference internal" href="../_modules/searx/botdetection/link_token.html#is_suspicious"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.botdetection.link_token.is_suspicious" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Checks whether a valid ping is exists for this (client) network, if not
|
||||
this request is rated as <em>suspicious</em>. If a valid ping exists and argument
|
||||
<code class="docutils literal notranslate"><span class="pre">renew</span></code> is <code class="docutils literal notranslate"><span class="pre">True</span></code> the expire time of this ping is reset to
|
||||
<a class="reference internal" href="#searx.botdetection.link_token.PING_LIVE_TIME" title="searx.botdetection.link_token.PING_LIVE_TIME"><code class="xref py py-obj docutils literal notranslate"><span class="pre">PING_LIVE_TIME</span></code></a>.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.botdetection.link_token.ping">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.botdetection.link_token.</span></span><span class="sig-name descname"><span class="pre">ping</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">request</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="../dev/extended_types.html#searx.extended_types.SXNG_Request" title="searx.extended_types.SXNG_Request"><span class="pre">SXNG_Request</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">token</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><a class="reference internal" href="../_modules/searx/botdetection/link_token.html#ping"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.botdetection.link_token.ping" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>This function is called by a request to URL <code class="docutils literal notranslate"><span class="pre">/client<token>.css</span></code>. If
|
||||
<code class="docutils literal notranslate"><span class="pre">token</span></code> is valid a <a class="reference internal" href="#searx.botdetection.link_token.PING_KEY" title="searx.botdetection.link_token.PING_KEY"><code class="xref py py-obj docutils literal notranslate"><span class="pre">PING_KEY</span></code></a> for the client is stored in the DB.
|
||||
The expire time of this ping-key is <a class="reference internal" href="#searx.botdetection.link_token.PING_LIVE_TIME" title="searx.botdetection.link_token.PING_LIVE_TIME"><code class="xref py py-obj docutils literal notranslate"><span class="pre">PING_LIVE_TIME</span></code></a>.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.botdetection.link_token.get_ping_key">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.botdetection.link_token.</span></span><span class="sig-name descname"><span class="pre">get_ping_key</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">network</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/ipaddress.html#ipaddress.IPv4Network" title="(in Python v3.13)"><span class="pre">IPv4Network</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/ipaddress.html#ipaddress.IPv6Network" title="(in Python v3.13)"><span class="pre">IPv6Network</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">request</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="../dev/extended_types.html#searx.extended_types.SXNG_Request" title="searx.extended_types.SXNG_Request"><span class="pre">SXNG_Request</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</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/botdetection/link_token.html#get_ping_key"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.botdetection.link_token.get_ping_key" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Generates a hashed key that fits (more or less) to a <em>WEB-browser
|
||||
session</em> in a network.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.botdetection.link_token.get_token">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.botdetection.link_token.</span></span><span class="sig-name descname"><span class="pre">get_token</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</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/botdetection/link_token.html#get_token"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.botdetection.link_token.get_token" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Returns current token. If there is no currently active token a new token
|
||||
is generated randomly and stored in the redis DB.</p>
|
||||
<ul class="simple">
|
||||
<li><p><a class="reference internal" href="#searx.botdetection.link_token.TOKEN_LIVE_TIME" title="searx.botdetection.link_token.TOKEN_LIVE_TIME"><code class="xref py py-obj docutils literal notranslate"><span class="pre">TOKEN_LIVE_TIME</span></code></a></p></li>
|
||||
<li><p><a class="reference internal" href="#searx.botdetection.link_token.TOKEN_KEY" title="searx.botdetection.link_token.TOKEN_KEY"><code class="xref py py-obj docutils literal notranslate"><span class="pre">TOKEN_KEY</span></code></a></p></li>
|
||||
</ul>
|
||||
</dd></dl>
|
||||
|
||||
</section>
|
||||
<section id="module-searx.botdetection.http_accept">
|
||||
<span id="probe-http-headers"></span><span id="botdetection-probe-headers"></span><h2><a class="toc-backref" href="#id9" role="doc-backlink">Probe HTTP headers</a><a class="headerlink" href="#module-searx.botdetection.http_accept" title="Link to this heading">¶</a></h2>
|
||||
<section id="method-http-accept">
|
||||
<h3><a class="toc-backref" href="#id10" role="doc-backlink">Method <code class="docutils literal notranslate"><span class="pre">http_accept</span></code></a><a class="headerlink" href="#method-http-accept" title="Link to this heading">¶</a></h3>
|
||||
<p>The <code class="docutils literal notranslate"><span class="pre">http_accept</span></code> method evaluates a request as the request of a bot if the
|
||||
<a class="reference external" href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept">Accept</a> header ..</p>
|
||||
<ul class="simple">
|
||||
<li><p>did not contain <code class="docutils literal notranslate"><span class="pre">text/html</span></code></p></li>
|
||||
</ul>
|
||||
</section>
|
||||
<section id="method-http-accept-encoding">
|
||||
<span id="module-searx.botdetection.http_accept_encoding"></span><h3><a class="toc-backref" href="#id11" role="doc-backlink">Method <code class="docutils literal notranslate"><span class="pre">http_accept_encoding</span></code></a><a class="headerlink" href="#method-http-accept-encoding" title="Link to this heading">¶</a></h3>
|
||||
<p>The <code class="docutils literal notranslate"><span class="pre">http_accept_encoding</span></code> method evaluates a request as the request of a
|
||||
bot if the <a class="reference external" href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding">Accept-Encoding</a> header ..</p>
|
||||
<ul class="simple">
|
||||
<li><p>did not contain <code class="docutils literal notranslate"><span class="pre">gzip</span></code> AND <code class="docutils literal notranslate"><span class="pre">deflate</span></code> (if both values are missed)</p></li>
|
||||
<li><p>did not contain <code class="docutils literal notranslate"><span class="pre">text/html</span></code></p></li>
|
||||
</ul>
|
||||
</section>
|
||||
<section id="method-http-accept-language">
|
||||
<span id="module-searx.botdetection.http_accept_language"></span><h3><a class="toc-backref" href="#id12" role="doc-backlink">Method <code class="docutils literal notranslate"><span class="pre">http_accept_language</span></code></a><a class="headerlink" href="#method-http-accept-language" title="Link to this heading">¶</a></h3>
|
||||
<p>The <code class="docutils literal notranslate"><span class="pre">http_accept_language</span></code> method evaluates a request as the request of a bot
|
||||
if the <a class="reference external" href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent">Accept-Language</a> header is unset.</p>
|
||||
</section>
|
||||
<section id="method-http-connection">
|
||||
<span id="module-searx.botdetection.http_connection"></span><h3><a class="toc-backref" href="#id13" role="doc-backlink">Method <code class="docutils literal notranslate"><span class="pre">http_connection</span></code></a><a class="headerlink" href="#method-http-connection" title="Link to this heading">¶</a></h3>
|
||||
<p>The <code class="docutils literal notranslate"><span class="pre">http_connection</span></code> method evaluates a request as the request of a bot if
|
||||
the <a class="reference external" href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Connection">Connection</a> header is set to <code class="docutils literal notranslate"><span class="pre">close</span></code>.</p>
|
||||
</section>
|
||||
<section id="method-http-user-agent">
|
||||
<span id="module-searx.botdetection.http_user_agent"></span><h3><a class="toc-backref" href="#id14" role="doc-backlink">Method <code class="docutils literal notranslate"><span class="pre">http_user_agent</span></code></a><a class="headerlink" href="#method-http-user-agent" title="Link to this heading">¶</a></h3>
|
||||
<p>The <code class="docutils literal notranslate"><span class="pre">http_user_agent</span></code> method evaluates a request as the request of a bot if
|
||||
the <a class="reference external" href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent">User-Agent</a> header is unset or matches the regular expression
|
||||
<a class="reference internal" href="#searx.botdetection.http_user_agent.USER_AGENT" title="searx.botdetection.http_user_agent.USER_AGENT"><code class="xref py py-obj docutils literal notranslate"><span class="pre">USER_AGENT</span></code></a>.</p>
|
||||
</section>
|
||||
<dl class="py data">
|
||||
<dt class="sig sig-object py" id="searx.botdetection.http_user_agent.USER_AGENT">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.botdetection.http_user_agent.</span></span><span class="sig-name descname"><span class="pre">USER_AGENT</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">'(unknown|[Cc][Uu][Rr][Ll]|[wW]get|Scrapy|splash|JavaFX|FeedFetcher|python-requests|Go-http-client|Java|Jakarta|okhttp|HttpClient|Jersey|Python|libwww-perl|Ruby|SynHttpClient|UniversalFeedParser|Googlebot|GoogleImageProxy|bingbot|Baiduspider|yacybot|YandexMobileBot|YandexBot|Yahoo!</span> <span class="pre">Slurp|MJ12bot|AhrefsBot|archive.org_bot|msnbot|MJ12bot|SeznamBot|linkdexbot|Netvibes|SMTBot|zgrab|James</span> <span class="pre">BOT|Sogou|Abonti|Pixray|Spinn3r|SemrushBot|Exabot|ZmEu|BLEXBot|bitlybot|HeadlessChrome|Mozilla/5\\.0\\</span> <span class="pre">\\(compatible;\\</span> <span class="pre">Farside/0\\.1\\.0;\\</span> <span class="pre">\\+https://farside\\.link\\)|.*PetalBot.*)'</span></em><a class="headerlink" href="#searx.botdetection.http_user_agent.USER_AGENT" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Regular expression that matches to <a class="reference external" href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent">User-Agent</a> from known <em>bots</em></p>
|
||||
</dd></dl>
|
||||
|
||||
</section>
|
||||
<section id="module-searx.botdetection.config">
|
||||
<span id="config"></span><span id="botdetection-config"></span><h2><a class="toc-backref" href="#id15" role="doc-backlink">Config</a><a class="headerlink" href="#module-searx.botdetection.config" title="Link to this heading">¶</a></h2>
|
||||
<p>Configuration class <a class="reference internal" href="#searx.botdetection.config.Config" title="searx.botdetection.config.Config"><code class="xref py py-class docutils literal notranslate"><span class="pre">Config</span></code></a> with deep-update, schema validation
|
||||
and deprecated names.</p>
|
||||
<p>The <a class="reference internal" href="#searx.botdetection.config.Config" title="searx.botdetection.config.Config"><code class="xref py py-class docutils literal notranslate"><span class="pre">Config</span></code></a> class implements a configuration that is based on
|
||||
structured dictionaries. The configuration schema is defined in a dictionary
|
||||
structure and the configuration data is given in a dictionary structure.</p>
|
||||
<dl class="py class">
|
||||
<dt class="sig sig-object py" id="searx.botdetection.config.Config">
|
||||
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">searx.botdetection.config.</span></span><span class="sig-name descname"><span class="pre">Config</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cfg_schema</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.Dict" title="(in Python v3.13)"><span class="pre">Dict</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">deprecated</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.Dict" title="(in Python v3.13)"><span class="pre">Dict</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><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><a class="reference internal" href="../_modules/searx/botdetection/config.html#Config"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.botdetection.config.Config" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Base class used for configuration</p>
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.botdetection.config.Config.validate">
|
||||
<span class="sig-name descname"><span class="pre">validate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cfg</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#dict" title="(in Python v3.13)"><span class="pre">dict</span></a></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/botdetection/config.html#Config.validate"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.botdetection.config.Config.validate" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Validation of dictionary <code class="docutils literal notranslate"><span class="pre">cfg</span></code> on <code class="xref py py-obj docutils literal notranslate"><span class="pre">Config.SCHEMA</span></code>.
|
||||
Validation is done by <a class="reference internal" href="#searx.botdetection.config.Config.validate" title="searx.botdetection.config.Config.validate"><code class="xref py py-obj docutils literal notranslate"><span class="pre">validate</span></code></a>.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.botdetection.config.Config.update">
|
||||
<span class="sig-name descname"><span class="pre">update</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">upd_cfg</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#dict" title="(in Python v3.13)"><span class="pre">dict</span></a></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/botdetection/config.html#Config.update"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.botdetection.config.Config.update" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Update this configuration by <code class="docutils literal notranslate"><span class="pre">upd_cfg</span></code>.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.botdetection.config.Config.default">
|
||||
<span class="sig-name descname"><span class="pre">default</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><a class="reference internal" href="../_modules/searx/botdetection/config.html#Config.default"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.botdetection.config.Config.default" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Returns default value of field <code class="docutils literal notranslate"><span class="pre">name</span></code> in <code class="docutils literal notranslate"><span class="pre">self.cfg_schema</span></code>.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.botdetection.config.Config.get">
|
||||
<span class="sig-name descname"><span class="pre">get</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name:</span> <span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">default:</span> <span class="pre">~typing.Any</span> <span class="pre">=</span> <span class="pre"><UNSET></span></span></em>, <em class="sig-param"><span class="n"><span class="pre">replace:</span> <span class="pre">bool</span> <span class="pre">=</span> <span class="pre">True</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><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></span><a class="reference internal" href="../_modules/searx/botdetection/config.html#Config.get"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.botdetection.config.Config.get" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Returns the value to which <code class="docutils literal notranslate"><span class="pre">name</span></code> points in the configuration.</p>
|
||||
<p>If there is no such <code class="docutils literal notranslate"><span class="pre">name</span></code> in the config and the <code class="docutils literal notranslate"><span class="pre">default</span></code> is
|
||||
<code class="xref py py-obj docutils literal notranslate"><span class="pre">UNSET</span></code>, a <a class="reference external" href="https://docs.python.org/3/library/exceptions.html#KeyError" title="(in Python v3.13)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">KeyError</span></code></a> is raised.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.botdetection.config.Config.set">
|
||||
<span class="sig-name descname"><span class="pre">set</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>, <em class="sig-param"><span class="n"><span class="pre">val</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/botdetection/config.html#Config.set"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.botdetection.config.Config.set" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Set the value to which <code class="docutils literal notranslate"><span class="pre">name</span></code> points in the configuration.</p>
|
||||
<p>If there is no such <code class="docutils literal notranslate"><span class="pre">name</span></code> in the config, a <a class="reference external" href="https://docs.python.org/3/library/exceptions.html#KeyError" title="(in Python v3.13)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">KeyError</span></code></a> is
|
||||
raised.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.botdetection.config.Config.path">
|
||||
<span class="sig-name descname"><span class="pre">path</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name:</span> <span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">default=<UNSET></span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/botdetection/config.html#Config.path"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.botdetection.config.Config.path" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Get a <a class="reference external" href="https://docs.python.org/3/library/pathlib.html#pathlib.Path" title="(in Python v3.13)"><code class="xref py py-class docutils literal notranslate"><span class="pre">pathlib.Path</span></code></a> object from a config string.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.botdetection.config.Config.pyobj">
|
||||
<span class="sig-name descname"><span class="pre">pyobj</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">default=<UNSET></span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/botdetection/config.html#Config.pyobj"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.botdetection.config.Config.pyobj" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Get python object referred by full qualiffied name (FQN) in the config
|
||||
string.</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py exception">
|
||||
<dt class="sig sig-object py" id="searx.botdetection.config.SchemaIssue">
|
||||
<em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">searx.botdetection.config.</span></span><span class="sig-name descname"><span class="pre">SchemaIssue</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">level</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.Literal" title="(in Python v3.13)"><span class="pre">Literal</span></a><span class="p"><span class="pre">[</span></span><span class="s"><span class="pre">'warn'</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="s"><span class="pre">'invalid'</span></span><span class="p"><span class="pre">]</span></span></span></em>, <em class="sig-param"><span class="n"><span class="pre">msg</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><a class="reference internal" href="../_modules/searx/botdetection/config.html#SchemaIssue"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.botdetection.config.SchemaIssue" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Exception to store and/or raise a message from a schema issue.</p>
|
||||
</dd></dl>
|
||||
|
||||
</section>
|
||||
</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 current"><a class="current reference internal" href="#">Bot Detection</a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.botdetection.get_network"><code class="docutils literal notranslate"><span class="pre">get_network()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.botdetection.get_real_ip"><code class="docutils literal notranslate"><span class="pre">get_real_ip()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.botdetection.too_many_requests"><code class="docutils literal notranslate"><span class="pre">too_many_requests()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#module-searx.botdetection.ip_lists">IP lists</a><ul>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#method-ip-lists">Method <code class="docutils literal notranslate"><span class="pre">ip_lists</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.botdetection.ip_lists.SEARXNG_ORG"><code class="docutils literal notranslate"><span class="pre">SEARXNG_ORG</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.botdetection.ip_lists.pass_ip"><code class="docutils literal notranslate"><span class="pre">pass_ip()</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.botdetection.ip_lists.block_ip"><code class="docutils literal notranslate"><span class="pre">block_ip()</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#module-searx.botdetection.ip_limit">Rate limit</a><ul>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#method-ip-limit">Method <code class="docutils literal notranslate"><span class="pre">ip_limit</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.botdetection.ip_limit.BURST_WINDOW"><code class="docutils literal notranslate"><span class="pre">BURST_WINDOW</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.botdetection.ip_limit.BURST_MAX"><code class="docutils literal notranslate"><span class="pre">BURST_MAX</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.botdetection.ip_limit.BURST_MAX_SUSPICIOUS"><code class="docutils literal notranslate"><span class="pre">BURST_MAX_SUSPICIOUS</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.botdetection.ip_limit.LONG_WINDOW"><code class="docutils literal notranslate"><span class="pre">LONG_WINDOW</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.botdetection.ip_limit.LONG_MAX"><code class="docutils literal notranslate"><span class="pre">LONG_MAX</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.botdetection.ip_limit.LONG_MAX_SUSPICIOUS"><code class="docutils literal notranslate"><span class="pre">LONG_MAX_SUSPICIOUS</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.botdetection.ip_limit.API_WINDOW"><code class="docutils literal notranslate"><span class="pre">API_WINDOW</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.botdetection.ip_limit.API_MAX"><code class="docutils literal notranslate"><span class="pre">API_MAX</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.botdetection.ip_limit.SUSPICIOUS_IP_WINDOW"><code class="docutils literal notranslate"><span class="pre">SUSPICIOUS_IP_WINDOW</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.botdetection.ip_limit.SUSPICIOUS_IP_MAX"><code class="docutils literal notranslate"><span class="pre">SUSPICIOUS_IP_MAX</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#method-link-token">Method <code class="docutils literal notranslate"><span class="pre">link_token</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.botdetection.link_token.TOKEN_LIVE_TIME"><code class="docutils literal notranslate"><span class="pre">TOKEN_LIVE_TIME</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.botdetection.link_token.PING_LIVE_TIME"><code class="docutils literal notranslate"><span class="pre">PING_LIVE_TIME</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.botdetection.link_token.PING_KEY"><code class="docutils literal notranslate"><span class="pre">PING_KEY</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.botdetection.link_token.TOKEN_KEY"><code class="docutils literal notranslate"><span class="pre">TOKEN_KEY</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.botdetection.link_token.is_suspicious"><code class="docutils literal notranslate"><span class="pre">is_suspicious()</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.botdetection.link_token.ping"><code class="docutils literal notranslate"><span class="pre">ping()</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.botdetection.link_token.get_ping_key"><code class="docutils literal notranslate"><span class="pre">get_ping_key()</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.botdetection.link_token.get_token"><code class="docutils literal notranslate"><span class="pre">get_token()</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#module-searx.botdetection.http_accept">Probe HTTP headers</a><ul>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#method-http-accept">Method <code class="docutils literal notranslate"><span class="pre">http_accept</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#method-http-accept-encoding">Method <code class="docutils literal notranslate"><span class="pre">http_accept_encoding</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#method-http-accept-language">Method <code class="docutils literal notranslate"><span class="pre">http_accept_language</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#method-http-connection">Method <code class="docutils literal notranslate"><span class="pre">http_connection</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#method-http-user-agent">Method <code class="docutils literal notranslate"><span class="pre">http_user_agent</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.botdetection.http_user_agent.USER_AGENT"><code class="docutils literal notranslate"><span class="pre">USER_AGENT</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#module-searx.botdetection.config">Config</a><ul>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.botdetection.config.Config"><code class="docutils literal notranslate"><span class="pre">Config</span></code></a><ul>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.botdetection.config.Config.validate"><code class="docutils literal notranslate"><span class="pre">Config.validate()</span></code></a></li>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.botdetection.config.Config.update"><code class="docutils literal notranslate"><span class="pre">Config.update()</span></code></a></li>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.botdetection.config.Config.default"><code class="docutils literal notranslate"><span class="pre">Config.default()</span></code></a></li>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.botdetection.config.Config.get"><code class="docutils literal notranslate"><span class="pre">Config.get()</span></code></a></li>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.botdetection.config.Config.set"><code class="docutils literal notranslate"><span class="pre">Config.set()</span></code></a></li>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.botdetection.config.Config.path"><code class="docutils literal notranslate"><span class="pre">Config.path()</span></code></a></li>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.botdetection.config.Config.pyobj"><code class="docutils literal notranslate"><span class="pre">Config.pyobj()</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.botdetection.config.SchemaIssue"><code class="docutils literal notranslate"><span class="pre">SchemaIssue</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</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.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"><a class="reference internal" href="searx.utils.html">Utility functions for the engines</a></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.babel_extract.html" title="previous chapter">Custom message extractor (i18n)</a>
|
||||
<li>Next: <a href="searx.exceptions.html" title="next chapter">SearXNG Exceptions</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.botdetection.rst.txt"
|
||||
rel="nofollow">Show Source</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright SearXNG team.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
247
src/searx.exceptions.html
Normal file
247
src/searx.exceptions.html
Normal file
@@ -0,0 +1,247 @@
|
||||
<!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>SearXNG Exceptions — SearXNG Documentation (2025.4.11+2287a6826)</title>
|
||||
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=6625fa76" />
|
||||
<link rel="stylesheet" type="text/css" href="../_static/searxng.css?v=52e4ff28" />
|
||||
<script src="../_static/documentation_options.js?v=725693a2"></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.4.11+2287a6826" 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="next" title="Favicons (source)" href="searx.favicons.html" />
|
||||
<link rel="prev" title="Bot Detection" href="searx.botdetection.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.favicons.html" title="Favicons (source)"
|
||||
accesskey="N">next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="searx.botdetection.html" title="Bot Detection"
|
||||
accesskey="P">previous</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../index.html">SearXNG Documentation (2025.4.11+2287a6826)</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Source-Code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">SearXNG Exceptions</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<section id="module-searx.exceptions">
|
||||
<span id="searxng-exceptions"></span><span id="searx-exceptions"></span><h1>SearXNG Exceptions<a class="headerlink" href="#module-searx.exceptions" title="Link to this heading">¶</a></h1>
|
||||
<p>Exception types raised by SearXNG modules.</p>
|
||||
<dl class="py exception">
|
||||
<dt class="sig sig-object py" id="searx.exceptions.SearxException">
|
||||
<em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">searx.exceptions.</span></span><span class="sig-name descname"><span class="pre">SearxException</span></span><a class="reference internal" href="../_modules/searx/exceptions.html#SearxException"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.exceptions.SearxException" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Base SearXNG exception.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py exception">
|
||||
<dt class="sig sig-object py" id="searx.exceptions.SearxParameterException">
|
||||
<em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">searx.exceptions.</span></span><span class="sig-name descname"><span class="pre">SearxParameterException</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/exceptions.html#SearxParameterException"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.exceptions.SearxParameterException" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Raised when query miss a required parameter</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py exception">
|
||||
<dt class="sig sig-object py" id="searx.exceptions.SearxSettingsException">
|
||||
<em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">searx.exceptions.</span></span><span class="sig-name descname"><span class="pre">SearxSettingsException</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">message</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/exceptions.html#Exception" title="(in Python v3.13)"><span class="pre">Exception</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">filename</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></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/exceptions.html#SearxSettingsException"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.exceptions.SearxSettingsException" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Error while loading the settings</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py exception">
|
||||
<dt class="sig sig-object py" id="searx.exceptions.SearxEngineException">
|
||||
<em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">searx.exceptions.</span></span><span class="sig-name descname"><span class="pre">SearxEngineException</span></span><a class="reference internal" href="../_modules/searx/exceptions.html#SearxEngineException"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.exceptions.SearxEngineException" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Error inside an engine</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py exception">
|
||||
<dt class="sig sig-object py" id="searx.exceptions.SearxXPathSyntaxException">
|
||||
<em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">searx.exceptions.</span></span><span class="sig-name descname"><span class="pre">SearxXPathSyntaxException</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">xpath_spec</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">message</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/exceptions.html#SearxXPathSyntaxException"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.exceptions.SearxXPathSyntaxException" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Syntax error in a XPATH</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py exception">
|
||||
<dt class="sig sig-object py" id="searx.exceptions.SearxEngineResponseException">
|
||||
<em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">searx.exceptions.</span></span><span class="sig-name descname"><span class="pre">SearxEngineResponseException</span></span><a class="reference internal" href="../_modules/searx/exceptions.html#SearxEngineResponseException"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.exceptions.SearxEngineResponseException" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Impossible to parse the result of an engine</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py exception">
|
||||
<dt class="sig sig-object py" id="searx.exceptions.SearxEngineAPIException">
|
||||
<em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">searx.exceptions.</span></span><span class="sig-name descname"><span class="pre">SearxEngineAPIException</span></span><a class="reference internal" href="../_modules/searx/exceptions.html#SearxEngineAPIException"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.exceptions.SearxEngineAPIException" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>The website has returned an application error</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py exception">
|
||||
<dt class="sig sig-object py" id="searx.exceptions.SearxEngineAccessDeniedException">
|
||||
<em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">searx.exceptions.</span></span><span class="sig-name descname"><span class="pre">SearxEngineAccessDeniedException</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">suspended_time</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>, <em class="sig-param"><span class="n"><span class="pre">message</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">'Access</span> <span class="pre">denied'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/exceptions.html#SearxEngineAccessDeniedException"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.exceptions.SearxEngineAccessDeniedException" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>The website is blocking the access</p>
|
||||
<dl class="py attribute">
|
||||
<dt class="sig sig-object py" id="searx.exceptions.SearxEngineAccessDeniedException.SUSPEND_TIME_SETTING">
|
||||
<span class="sig-name descname"><span class="pre">SUSPEND_TIME_SETTING</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">'search.suspended_times.SearxEngineAccessDenied'</span></em><a class="headerlink" href="#searx.exceptions.SearxEngineAccessDeniedException.SUSPEND_TIME_SETTING" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>This settings contains the default suspended time (default 86400 sec / 1
|
||||
day).</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py exception">
|
||||
<dt class="sig sig-object py" id="searx.exceptions.SearxEngineCaptchaException">
|
||||
<em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">searx.exceptions.</span></span><span class="sig-name descname"><span class="pre">SearxEngineCaptchaException</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">suspended_time</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>, <em class="sig-param"><span class="n"><span class="pre">message</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'CAPTCHA'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/exceptions.html#SearxEngineCaptchaException"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.exceptions.SearxEngineCaptchaException" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>The website has returned a CAPTCHA.</p>
|
||||
<dl class="py attribute">
|
||||
<dt class="sig sig-object py" id="searx.exceptions.SearxEngineCaptchaException.SUSPEND_TIME_SETTING">
|
||||
<span class="sig-name descname"><span class="pre">SUSPEND_TIME_SETTING</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">'search.suspended_times.SearxEngineCaptcha'</span></em><a class="headerlink" href="#searx.exceptions.SearxEngineCaptchaException.SUSPEND_TIME_SETTING" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>This settings contains the default suspended time (default 86400 sec / 1
|
||||
day).</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py exception">
|
||||
<dt class="sig sig-object py" id="searx.exceptions.SearxEngineTooManyRequestsException">
|
||||
<em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">searx.exceptions.</span></span><span class="sig-name descname"><span class="pre">SearxEngineTooManyRequestsException</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">suspended_time</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>, <em class="sig-param"><span class="n"><span class="pre">message</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'Too</span> <span class="pre">many</span> <span class="pre">request'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/exceptions.html#SearxEngineTooManyRequestsException"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.exceptions.SearxEngineTooManyRequestsException" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>The website has returned a Too Many Request status code</p>
|
||||
<p>By default, searx stops sending requests to this engine for 1 hour.</p>
|
||||
<dl class="py attribute">
|
||||
<dt class="sig sig-object py" id="searx.exceptions.SearxEngineTooManyRequestsException.SUSPEND_TIME_SETTING">
|
||||
<span class="sig-name descname"><span class="pre">SUSPEND_TIME_SETTING</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">'search.suspended_times.SearxEngineTooManyRequests'</span></em><a class="headerlink" href="#searx.exceptions.SearxEngineTooManyRequestsException.SUSPEND_TIME_SETTING" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>This settings contains the default suspended time (default 3660 sec / 1
|
||||
hour).</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py exception">
|
||||
<dt class="sig sig-object py" id="searx.exceptions.SearxEngineXPathException">
|
||||
<em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">searx.exceptions.</span></span><span class="sig-name descname"><span class="pre">SearxEngineXPathException</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">xpath_spec</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">message</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/exceptions.html#SearxEngineXPathException"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.exceptions.SearxEngineXPathException" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Error while getting the result of an XPath expression</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 current"><a class="current reference internal" href="#">SearXNG Exceptions</a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.exceptions.SearxException"><code class="docutils literal notranslate"><span class="pre">SearxException</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.exceptions.SearxParameterException"><code class="docutils literal notranslate"><span class="pre">SearxParameterException</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.exceptions.SearxSettingsException"><code class="docutils literal notranslate"><span class="pre">SearxSettingsException</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.exceptions.SearxEngineException"><code class="docutils literal notranslate"><span class="pre">SearxEngineException</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.exceptions.SearxXPathSyntaxException"><code class="docutils literal notranslate"><span class="pre">SearxXPathSyntaxException</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.exceptions.SearxEngineResponseException"><code class="docutils literal notranslate"><span class="pre">SearxEngineResponseException</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.exceptions.SearxEngineAPIException"><code class="docutils literal notranslate"><span class="pre">SearxEngineAPIException</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.exceptions.SearxEngineAccessDeniedException"><code class="docutils literal notranslate"><span class="pre">SearxEngineAccessDeniedException</span></code></a><ul>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.exceptions.SearxEngineAccessDeniedException.SUSPEND_TIME_SETTING"><code class="docutils literal notranslate"><span class="pre">SearxEngineAccessDeniedException.SUSPEND_TIME_SETTING</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.exceptions.SearxEngineCaptchaException"><code class="docutils literal notranslate"><span class="pre">SearxEngineCaptchaException</span></code></a><ul>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.exceptions.SearxEngineCaptchaException.SUSPEND_TIME_SETTING"><code class="docutils literal notranslate"><span class="pre">SearxEngineCaptchaException.SUSPEND_TIME_SETTING</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.exceptions.SearxEngineTooManyRequestsException"><code class="docutils literal notranslate"><span class="pre">SearxEngineTooManyRequestsException</span></code></a><ul>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.exceptions.SearxEngineTooManyRequestsException.SUSPEND_TIME_SETTING"><code class="docutils literal notranslate"><span class="pre">SearxEngineTooManyRequestsException.SUSPEND_TIME_SETTING</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.exceptions.SearxEngineXPathException"><code class="docutils literal notranslate"><span class="pre">SearxEngineXPathException</span></code></a></li>
|
||||
</ul>
|
||||
</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.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"><a class="reference internal" href="searx.utils.html">Utility functions for the engines</a></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.botdetection.html" title="previous chapter">Bot Detection</a>
|
||||
<li>Next: <a href="searx.favicons.html" title="next chapter">Favicons (source)</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.exceptions.rst.txt"
|
||||
rel="nofollow">Show Source</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright SearXNG team.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
716
src/searx.favicons.html
Normal file
716
src/searx.favicons.html
Normal file
@@ -0,0 +1,716 @@
|
||||
<!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>Favicons (source) — SearXNG Documentation (2025.4.11+2287a6826)</title>
|
||||
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=6625fa76" />
|
||||
<link rel="stylesheet" type="text/css" href="../_static/searxng.css?v=52e4ff28" />
|
||||
<script src="../_static/documentation_options.js?v=725693a2"></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.4.11+2287a6826" 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="next" title="Online /info" href="searx.infopage.html" />
|
||||
<link rel="prev" title="SearXNG Exceptions" href="searx.exceptions.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.infopage.html" title="Online /info"
|
||||
accesskey="N">next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="searx.exceptions.html" title="SearXNG Exceptions"
|
||||
accesskey="P">previous</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../index.html">SearXNG Documentation (2025.4.11+2287a6826)</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Source-Code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">Favicons (source)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<section id="favicons-source">
|
||||
<span id="id1"></span><h1>Favicons (source)<a class="headerlink" href="#favicons-source" title="Link to this heading">¶</a></h1>
|
||||
<nav class="contents local" id="contents">
|
||||
<ul class="simple">
|
||||
<li><p><a class="reference internal" href="#module-searx.favicons.config" id="id7">Favicons Config</a></p></li>
|
||||
<li><p><a class="reference internal" href="#module-searx.favicons.proxy" id="id8">Favicons Proxy</a></p></li>
|
||||
<li><p><a class="reference internal" href="#module-searx.favicons.resolvers" id="id9">Favicons Resolver</a></p></li>
|
||||
<li><p><a class="reference internal" href="#module-searx.favicons.cache" id="id10">Favicons Cache</a></p></li>
|
||||
</ul>
|
||||
</nav>
|
||||
<p id="module-searx.favicons">Implementations for providing the favicons in SearXNG</p>
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.favicons.favicon_url">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.favicons.</span></span><span class="sig-name descname"><span class="pre">favicon_url</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">authority</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">→</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/favicons/proxy.html#favicon_url"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.favicon_url" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Function to generate the image URL used for favicons in SearXNG’s result
|
||||
lists. The <code class="docutils literal notranslate"><span class="pre">authority</span></code> argument (aka netloc / <span class="target" id="index-0"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc3986.html"><strong>RFC 3986</strong></a>) is usually a
|
||||
(sub-) domain name. This function is used in the HTML (jinja) templates.</p>
|
||||
<div class="highlight-html notranslate"><div class="highlight"><pre><span></span><span class="p"><</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"favicon"</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">img</span> <span class="na">src</span><span class="o">=</span><span class="s">"{{ favicon_url(result.parsed_url.netloc) }}"</span><span class="p">></span>
|
||||
<span class="p"></</span><span class="nt">div</span><span class="p">></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>The returned URL is a route to <a class="reference internal" href="#searx.favicons.favicon_proxy" title="searx.favicons.favicon_proxy"><code class="xref py py-obj docutils literal notranslate"><span class="pre">favicon_proxy</span></code></a> REST API.</p>
|
||||
<p>If the favicon is already in the cache, the returned URL is a <a class="reference external" href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs">data URL</a>
|
||||
(something like <code class="docutils literal notranslate"><span class="pre">data:image/png;base64,...</span></code>). By generating a data url from
|
||||
the <a class="reference internal" href="#searx.favicons.cache.FaviconCache" title="searx.favicons.cache.FaviconCache"><code class="xref py py-obj docutils literal notranslate"><span class="pre">cache.FaviconCache</span></code></a>, additional HTTP roundtripps via the
|
||||
<a class="reference internal" href="#searx.favicons.favicon_proxy" title="searx.favicons.favicon_proxy"><code class="xref py py-obj docutils literal notranslate"><span class="pre">favicon_proxy</span></code></a> are saved. However, it must also be borne in mind
|
||||
that data urls are not cached in the client (web browser).</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.favicons.favicon_proxy">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.favicons.</span></span><span class="sig-name descname"><span class="pre">favicon_proxy</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/favicons/proxy.html#favicon_proxy"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.favicon_proxy" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>REST API of SearXNG’s favicon proxy service</p>
|
||||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>/favicon_proxy?authority=<...>&h=<...>
|
||||
</pre></div>
|
||||
</div>
|
||||
<dl class="simple">
|
||||
<dt><code class="docutils literal notranslate"><span class="pre">authority</span></code>:</dt><dd><p>Domain name <span class="target" id="index-1"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc3986.html"><strong>RFC 3986</strong></a> / see <a class="reference internal" href="#searx.favicons.favicon_url" title="searx.favicons.favicon_url"><code class="xref py py-obj docutils literal notranslate"><span class="pre">favicon_url</span></code></a></p>
|
||||
</dd>
|
||||
<dt><code class="docutils literal notranslate"><span class="pre">h</span></code>:</dt><dd><p>HMAC <span class="target" id="index-2"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc2104.html"><strong>RFC 2104</strong></a>, build up from the <a class="reference internal" href="../admin/settings/settings_server.html#settings-server"><span class="std std-ref">server.secret_key</span></a> setting.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<section id="module-searx.favicons.config">
|
||||
<span id="id2"></span><span id="favicons-config"></span><h2><a class="toc-backref" href="#id7" role="doc-backlink">Favicons Config</a><a class="headerlink" href="#module-searx.favicons.config" title="Link to this heading">¶</a></h2>
|
||||
<dl class="py data">
|
||||
<dt class="sig sig-object py" id="searx.favicons.config.CONFIG_SCHEMA">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.favicons.config.</span></span><span class="sig-name descname"><span class="pre">CONFIG_SCHEMA</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><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></em><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">1</span></em><a class="headerlink" href="#searx.favicons.config.CONFIG_SCHEMA" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Version of the configuration schema.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py data">
|
||||
<dt class="sig sig-object py" id="searx.favicons.config.TOML_CACHE_CFG">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.favicons.config.</span></span><span class="sig-name descname"><span class="pre">TOML_CACHE_CFG</span></span><em class="property"><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#dict" title="(in Python v3.13)"><span class="pre">dict</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><a class="reference internal" href="#searx.favicons.config.FaviconConfig" title="searx.favicons.config.FaviconConfig"><span class="pre">FaviconConfig</span></a><span class="p"><span class="pre">]</span></span></em><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">{}</span></em><a class="headerlink" href="#searx.favicons.config.TOML_CACHE_CFG" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Cache config objects by TOML’s filename.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py class">
|
||||
<dt class="sig sig-object py" id="searx.favicons.config.FaviconConfig">
|
||||
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">searx.favicons.config.</span></span><span class="sig-name descname"><span class="pre">FaviconConfig</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cfg_schema:</span> <span class="pre">int</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cache:</span> <span class="pre">~searx.favicons.cache.FaviconCacheConfig</span> <span class="pre">=</span> <span class="pre"><factory></span></span></em>, <em class="sig-param"><span class="n"><span class="pre">proxy:</span> <span class="pre">~searx.favicons.proxy.FaviconProxyConfig</span> <span class="pre">=</span> <span class="pre"><factory></span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/favicons/config.html#FaviconConfig"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.config.FaviconConfig" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>The class aggregates configurations of the favicon tools</p>
|
||||
<dl class="py attribute">
|
||||
<dt class="sig sig-object py" id="searx.favicons.config.FaviconConfig.cfg_schema">
|
||||
<span class="sig-name descname"><span class="pre">cfg_schema</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><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></em><a class="headerlink" href="#searx.favicons.config.FaviconConfig.cfg_schema" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Config’s schema version. The specification of the version of the schema
|
||||
is mandatory, currently only version <a class="reference internal" href="#searx.favicons.config.CONFIG_SCHEMA" title="searx.favicons.config.CONFIG_SCHEMA"><code class="xref py py-obj docutils literal notranslate"><span class="pre">CONFIG_SCHEMA</span></code></a> is supported.
|
||||
By specifying a version, it is possible to ensure downward compatibility in
|
||||
the event of future changes to the configuration schema</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py attribute">
|
||||
<dt class="sig sig-object py" id="searx.favicons.config.FaviconConfig.cache">
|
||||
<span class="sig-name descname"><span class="pre">cache</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><a class="reference internal" href="#searx.favicons.cache.FaviconCacheConfig" title="searx.favicons.cache.FaviconCacheConfig"><span class="pre">FaviconCacheConfig</span></a></em><a class="headerlink" href="#searx.favicons.config.FaviconConfig.cache" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Setup of the <a class="reference internal" href="#searx.favicons.cache.FaviconCacheConfig" title="searx.favicons.cache.FaviconCacheConfig"><code class="xref py py-obj docutils literal notranslate"><span class="pre">cache.FaviconCacheConfig</span></code></a>.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py attribute">
|
||||
<dt class="sig sig-object py" id="searx.favicons.config.FaviconConfig.proxy">
|
||||
<span class="sig-name descname"><span class="pre">proxy</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><a class="reference internal" href="#searx.favicons.proxy.FaviconProxyConfig" title="searx.favicons.proxy.FaviconProxyConfig"><span class="pre">FaviconProxyConfig</span></a></em><a class="headerlink" href="#searx.favicons.config.FaviconConfig.proxy" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Setup of the <a class="reference internal" href="#searx.favicons.proxy.FaviconProxyConfig" title="searx.favicons.proxy.FaviconProxyConfig"><code class="xref py py-obj docutils literal notranslate"><span class="pre">proxy.FaviconProxyConfig</span></code></a>.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.favicons.config.FaviconConfig.from_toml_file">
|
||||
<em class="property"><span class="pre">classmethod</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">from_toml_file</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cfg_file</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/pathlib.html#pathlib.Path" title="(in Python v3.13)"><span class="pre">Path</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">use_cache</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></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><a class="reference internal" href="#searx.favicons.config.FaviconConfig" title="searx.favicons.config.FaviconConfig"><span class="pre">FaviconConfig</span></a></span></span><a class="reference internal" href="../_modules/searx/favicons/config.html#FaviconConfig.from_toml_file"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.config.FaviconConfig.from_toml_file" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Create a config object from a TOML file, the <code class="docutils literal notranslate"><span class="pre">use_cache</span></code> argument
|
||||
specifies whether a cache should be used.</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd></dl>
|
||||
|
||||
</section>
|
||||
<section id="module-searx.favicons.proxy">
|
||||
<span id="id3"></span><span id="favicons-proxy"></span><h2><a class="toc-backref" href="#id8" role="doc-backlink">Favicons Proxy</a><a class="headerlink" href="#module-searx.favicons.proxy" title="Link to this heading">¶</a></h2>
|
||||
<p>Implementations for a favicon proxy</p>
|
||||
<dl class="py class">
|
||||
<dt class="sig sig-object py" id="searx.favicons.proxy.FaviconProxyConfig">
|
||||
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">searx.favicons.proxy.</span></span><span class="sig-name descname"><span class="pre">FaviconProxyConfig</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">max_age:</span> <span class="pre">int</span> <span class="pre">=</span> <span class="pre">604800</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">secret_key:</span> <span class="pre">str</span> <span class="pre">=</span> <span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">resolver_timeout:</span> <span class="pre">int</span> <span class="pre">=</span> <span class="pre">3.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">resolver_map:</span> <span class="pre">dict[str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">str]</span> <span class="pre">=</span> <span class="pre"><factory></span></span></em>, <em class="sig-param"><span class="n"><span class="pre">favicon_path:</span> <span class="pre">str</span> <span class="pre">=</span> <span class="pre">'/home/runner/work/searxng/searxng/searx/static/themes/{theme}/img/empty_favicon.svg'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">favicon_mime_type:</span> <span class="pre">str</span> <span class="pre">=</span> <span class="pre">'image/svg+xml'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/favicons/proxy.html#FaviconProxyConfig"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.proxy.FaviconProxyConfig" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Configuration of the favicon proxy.</p>
|
||||
<dl class="py attribute">
|
||||
<dt class="sig sig-object py" id="searx.favicons.proxy.FaviconProxyConfig.max_age">
|
||||
<span class="sig-name descname"><span class="pre">max_age</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><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></em><a class="headerlink" href="#searx.favicons.proxy.FaviconProxyConfig.max_age" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>HTTP header <a class="reference external" href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control">Cache-Control</a> <code class="docutils literal notranslate"><span class="pre">max-age</span></code></p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py attribute">
|
||||
<dt class="sig sig-object py" id="searx.favicons.proxy.FaviconProxyConfig.secret_key">
|
||||
<span class="sig-name descname"><span class="pre">secret_key</span></span><em class="property"><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></em><a class="headerlink" href="#searx.favicons.proxy.FaviconProxyConfig.secret_key" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>By default, the value from <a class="reference internal" href="../admin/settings/settings_server.html#settings-server"><span class="std std-ref">server.secret_key</span></a>
|
||||
setting is used.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py attribute">
|
||||
<dt class="sig sig-object py" id="searx.favicons.proxy.FaviconProxyConfig.resolver_timeout">
|
||||
<span class="sig-name descname"><span class="pre">resolver_timeout</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><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></em><a class="headerlink" href="#searx.favicons.proxy.FaviconProxyConfig.resolver_timeout" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Timeout which the resolvers should not exceed, is usually passed to the
|
||||
outgoing request of the resolver. By default, the value from
|
||||
<a class="reference internal" href="../admin/settings/settings_outgoing.html#settings-outgoing"><span class="std std-ref">outgoing.request_timeout</span></a> setting is used.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py attribute">
|
||||
<dt class="sig sig-object py" id="searx.favicons.proxy.FaviconProxyConfig.resolver_map">
|
||||
<span class="sig-name descname"><span class="pre">resolver_map</span></span><em class="property"><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#dict" title="(in Python v3.13)"><span class="pre">dict</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><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></em><a class="headerlink" href="#searx.favicons.proxy.FaviconProxyConfig.resolver_map" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>The resolver_map is a key / value dictionary where the key is the name of
|
||||
the resolver and the value is the fully qualifying name (fqn) of resolver’s
|
||||
function (the callable). The resolvers from the python module
|
||||
<code class="xref py py-obj docutils literal notranslate"><span class="pre">searx.favicons.resolver</span></code> are available by default.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.favicons.proxy.FaviconProxyConfig.get_resolver">
|
||||
<span class="sig-name descname"><span class="pre">get_resolver</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">→</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Callable" title="(in Python v3.13)"><span class="pre">Callable</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/favicons/proxy.html#FaviconProxyConfig.get_resolver"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.proxy.FaviconProxyConfig.get_resolver" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Returns the callable object (function) of the resolver with the
|
||||
<code class="docutils literal notranslate"><span class="pre">name</span></code>. If no resolver is registered for the <code class="docutils literal notranslate"><span class="pre">name</span></code>, <code class="docutils literal notranslate"><span class="pre">None</span></code> is
|
||||
returned.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.favicons.proxy.FaviconProxyConfig.favicon">
|
||||
<span class="sig-name descname"><span class="pre">favicon</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">replacements</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/favicons/proxy.html#FaviconProxyConfig.favicon"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.proxy.FaviconProxyConfig.favicon" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Returns pathname and mimetype of the default favicon.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.favicons.proxy.FaviconProxyConfig.favicon_data_url">
|
||||
<span class="sig-name descname"><span class="pre">favicon_data_url</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">replacements</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/favicons/proxy.html#FaviconProxyConfig.favicon_data_url"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.proxy.FaviconProxyConfig.favicon_data_url" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Returns data image URL of the default favicon.</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.favicons.proxy.favicon_proxy">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.favicons.proxy.</span></span><span class="sig-name descname"><span class="pre">favicon_proxy</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/favicons/proxy.html#favicon_proxy"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.proxy.favicon_proxy" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>REST API of SearXNG’s favicon proxy service</p>
|
||||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>/favicon_proxy?authority=<...>&h=<...>
|
||||
</pre></div>
|
||||
</div>
|
||||
<dl class="simple">
|
||||
<dt><code class="docutils literal notranslate"><span class="pre">authority</span></code>:</dt><dd><p>Domain name <span class="target" id="index-3"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc3986.html"><strong>RFC 3986</strong></a> / see <a class="reference internal" href="#searx.favicons.proxy.favicon_url" title="searx.favicons.proxy.favicon_url"><code class="xref py py-obj docutils literal notranslate"><span class="pre">favicon_url</span></code></a></p>
|
||||
</dd>
|
||||
<dt><code class="docutils literal notranslate"><span class="pre">h</span></code>:</dt><dd><p>HMAC <span class="target" id="index-4"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc2104.html"><strong>RFC 2104</strong></a>, build up from the <a class="reference internal" href="../admin/settings/settings_server.html#settings-server"><span class="std std-ref">server.secret_key</span></a> setting.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.favicons.proxy.search_favicon">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.favicons.proxy.</span></span><span class="sig-name descname"><span class="pre">search_favicon</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">resolver</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">authority</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">→</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#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/constants.html#None" title="(in Python v3.13)"><span class="pre">None</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/stdtypes.html#bytes" title="(in Python v3.13)"><span class="pre">bytes</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/constants.html#None" title="(in Python v3.13)"><span class="pre">None</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/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a><span class="p"><span class="pre">]</span></span></span></span><a class="reference internal" href="../_modules/searx/favicons/proxy.html#search_favicon"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.proxy.search_favicon" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Sends the request to the favicon resolver and returns a tuple for the
|
||||
favicon. The tuple consists of <code class="docutils literal notranslate"><span class="pre">(data,</span> <span class="pre">mime)</span></code>, if the resolver has not
|
||||
determined a favicon, both values are <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p>
|
||||
<dl class="simple">
|
||||
<dt><code class="docutils literal notranslate"><span class="pre">data</span></code>:</dt><dd><p>Binary data of the favicon.</p>
|
||||
</dd>
|
||||
<dt><code class="docutils literal notranslate"><span class="pre">mime</span></code>:</dt><dd><p>Mime type of the favicon.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.favicons.proxy.favicon_url">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.favicons.proxy.</span></span><span class="sig-name descname"><span class="pre">favicon_url</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">authority</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">→</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/favicons/proxy.html#favicon_url"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.proxy.favicon_url" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Function to generate the image URL used for favicons in SearXNG’s result
|
||||
lists. The <code class="docutils literal notranslate"><span class="pre">authority</span></code> argument (aka netloc / <span class="target" id="index-5"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc3986.html"><strong>RFC 3986</strong></a>) is usually a
|
||||
(sub-) domain name. This function is used in the HTML (jinja) templates.</p>
|
||||
<div class="highlight-html notranslate"><div class="highlight"><pre><span></span><span class="p"><</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"favicon"</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">img</span> <span class="na">src</span><span class="o">=</span><span class="s">"{{ favicon_url(result.parsed_url.netloc) }}"</span><span class="p">></span>
|
||||
<span class="p"></</span><span class="nt">div</span><span class="p">></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>The returned URL is a route to <a class="reference internal" href="#searx.favicons.proxy.favicon_proxy" title="searx.favicons.proxy.favicon_proxy"><code class="xref py py-obj docutils literal notranslate"><span class="pre">favicon_proxy</span></code></a> REST API.</p>
|
||||
<p>If the favicon is already in the cache, the returned URL is a <a class="reference external" href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs">data URL</a>
|
||||
(something like <code class="docutils literal notranslate"><span class="pre">data:image/png;base64,...</span></code>). By generating a data url from
|
||||
the <a class="reference internal" href="#searx.favicons.cache.FaviconCache" title="searx.favicons.cache.FaviconCache"><code class="xref py py-obj docutils literal notranslate"><span class="pre">cache.FaviconCache</span></code></a>, additional HTTP roundtripps via the
|
||||
<a class="reference internal" href="#searx.favicons.proxy.favicon_proxy" title="searx.favicons.proxy.favicon_proxy"><code class="xref py py-obj docutils literal notranslate"><span class="pre">favicon_proxy</span></code></a> are saved. However, it must also be borne in mind
|
||||
that data urls are not cached in the client (web browser).</p>
|
||||
</dd></dl>
|
||||
|
||||
</section>
|
||||
<section id="module-searx.favicons.resolvers">
|
||||
<span id="id5"></span><span id="favicons-resolver"></span><h2><a class="toc-backref" href="#id9" role="doc-backlink">Favicons Resolver</a><a class="headerlink" href="#module-searx.favicons.resolvers" title="Link to this heading">¶</a></h2>
|
||||
<p>Implementations of the favicon <em>resolvers</em> that are available in the favicon
|
||||
proxy by default. A <em>resolver</em> is a function that obtains the favicon from an
|
||||
external source. The <em>resolver</em> function receives two arguments (<code class="docutils literal notranslate"><span class="pre">domain,</span>
|
||||
<span class="pre">timeout</span></code>) and returns a tuple <code class="docutils literal notranslate"><span class="pre">(data,</span> <span class="pre">mime)</span></code>.</p>
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.favicons.resolvers.allesedv">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.favicons.resolvers.</span></span><span class="sig-name descname"><span class="pre">allesedv</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">domain</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">timeout</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></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#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/constants.html#None" title="(in Python v3.13)"><span class="pre">None</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/stdtypes.html#bytes" title="(in Python v3.13)"><span class="pre">bytes</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/constants.html#None" title="(in Python v3.13)"><span class="pre">None</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/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a><span class="p"><span class="pre">]</span></span></span></span><a class="reference internal" href="../_modules/searx/favicons/resolvers.html#allesedv"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.resolvers.allesedv" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Favicon Resolver from allesedv.com / <a class="reference external" href="https://favicon.allesedv.com/">https://favicon.allesedv.com/</a></p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.favicons.resolvers.duckduckgo">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.favicons.resolvers.</span></span><span class="sig-name descname"><span class="pre">duckduckgo</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">domain</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">timeout</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></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#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/constants.html#None" title="(in Python v3.13)"><span class="pre">None</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/stdtypes.html#bytes" title="(in Python v3.13)"><span class="pre">bytes</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/constants.html#None" title="(in Python v3.13)"><span class="pre">None</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/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a><span class="p"><span class="pre">]</span></span></span></span><a class="reference internal" href="../_modules/searx/favicons/resolvers.html#duckduckgo"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.resolvers.duckduckgo" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Favicon Resolver from duckduckgo.com / <a class="reference external" href="https://blog.jim-nielsen.com/2021/displaying-favicons-for-any-domain/">https://blog.jim-nielsen.com/2021/displaying-favicons-for-any-domain/</a></p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.favicons.resolvers.google">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.favicons.resolvers.</span></span><span class="sig-name descname"><span class="pre">google</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">domain</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">timeout</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></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#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/constants.html#None" title="(in Python v3.13)"><span class="pre">None</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/stdtypes.html#bytes" title="(in Python v3.13)"><span class="pre">bytes</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/constants.html#None" title="(in Python v3.13)"><span class="pre">None</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/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a><span class="p"><span class="pre">]</span></span></span></span><a class="reference internal" href="../_modules/searx/favicons/resolvers.html#google"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.resolvers.google" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Favicon Resolver from google.com</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.favicons.resolvers.yandex">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.favicons.resolvers.</span></span><span class="sig-name descname"><span class="pre">yandex</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">domain</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">timeout</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></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#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/constants.html#None" title="(in Python v3.13)"><span class="pre">None</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/stdtypes.html#bytes" title="(in Python v3.13)"><span class="pre">bytes</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/constants.html#None" title="(in Python v3.13)"><span class="pre">None</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/stdtypes.html#str" title="(in Python v3.13)"><span class="pre">str</span></a><span class="p"><span class="pre">]</span></span></span></span><a class="reference internal" href="../_modules/searx/favicons/resolvers.html#yandex"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.resolvers.yandex" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Favicon Resolver from yandex.com</p>
|
||||
</dd></dl>
|
||||
|
||||
</section>
|
||||
<section id="module-searx.favicons.cache">
|
||||
<span id="id6"></span><span id="favicons-cache"></span><h2><a class="toc-backref" href="#id10" role="doc-backlink">Favicons Cache</a><a class="headerlink" href="#module-searx.favicons.cache" title="Link to this heading">¶</a></h2>
|
||||
<p>Implementations for caching favicons.</p>
|
||||
<dl class="simple">
|
||||
<dt><a class="reference internal" href="#searx.favicons.cache.FaviconCacheConfig" title="searx.favicons.cache.FaviconCacheConfig"><code class="xref py py-obj docutils literal notranslate"><span class="pre">FaviconCacheConfig</span></code></a>:</dt><dd><p>Configuration of the favicon cache</p>
|
||||
</dd>
|
||||
<dt><a class="reference internal" href="#searx.favicons.cache.FaviconCache" title="searx.favicons.cache.FaviconCache"><code class="xref py py-obj docutils literal notranslate"><span class="pre">FaviconCache</span></code></a>:</dt><dd><p>Abstract base class for the implementation of a favicon cache.</p>
|
||||
</dd>
|
||||
<dt><a class="reference internal" href="#searx.favicons.cache.FaviconCacheSQLite" title="searx.favicons.cache.FaviconCacheSQLite"><code class="xref py py-obj docutils literal notranslate"><span class="pre">FaviconCacheSQLite</span></code></a>:</dt><dd><p>Favicon cache that manages the favicon BLOBs in a SQLite DB.</p>
|
||||
</dd>
|
||||
<dt><a class="reference internal" href="#searx.favicons.cache.FaviconCacheNull" title="searx.favicons.cache.FaviconCacheNull"><code class="xref py py-obj docutils literal notranslate"><span class="pre">FaviconCacheNull</span></code></a>:</dt><dd><p>Fallback solution if the configured cache cannot be used for system reasons.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr class="docutils" />
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.favicons.cache.state">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.favicons.cache.</span></span><span class="sig-name descname"><span class="pre">state</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/favicons/cache.html#state"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.cache.state" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>show state of the cache</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.favicons.cache.maintenance">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.favicons.cache.</span></span><span class="sig-name descname"><span class="pre">maintenance</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">force</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">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">debug</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><a class="reference internal" href="../_modules/searx/favicons/cache.html#maintenance"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.cache.maintenance" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>perform maintenance of the cache</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.favicons.cache.init">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.favicons.cache.</span></span><span class="sig-name descname"><span class="pre">init</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cfg</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="#searx.favicons.cache.FaviconCacheConfig" title="searx.favicons.cache.FaviconCacheConfig"><span class="pre">FaviconCacheConfig</span></a></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/favicons/cache.html#init"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.cache.init" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Initialization of a global <code class="docutils literal notranslate"><span class="pre">CACHE</span></code></p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py class">
|
||||
<dt class="sig sig-object py" id="searx.favicons.cache.FaviconCacheConfig">
|
||||
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">searx.favicons.cache.</span></span><span class="sig-name descname"><span class="pre">FaviconCacheConfig</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">db_type</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.Literal" title="(in Python v3.13)"><span class="pre">Literal</span></a><span class="p"><span class="pre">[</span></span><span class="s"><span class="pre">'sqlite'</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="s"><span class="pre">'mem'</span></span><span class="p"><span class="pre">]</span></span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">'sqlite'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">db_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><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">'/tmp/faviconcache.db'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">HOLD_TIME</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><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">2592000</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">LIMIT_TOTAL_BYTES</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><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">52428800</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">BLOB_MAX_BYTES</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><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">20480</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">MAINTENANCE_PERIOD</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><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">3600</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">MAINTENANCE_MODE</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.Literal" title="(in Python v3.13)"><span class="pre">Literal</span></a><span class="p"><span class="pre">[</span></span><span class="s"><span class="pre">'auto'</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="s"><span class="pre">'off'</span></span><span class="p"><span class="pre">]</span></span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">'auto'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/favicons/cache.html#FaviconCacheConfig"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.cache.FaviconCacheConfig" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Configuration of the favicon cache.</p>
|
||||
<dl class="py attribute">
|
||||
<dt class="sig sig-object py" id="searx.favicons.cache.FaviconCacheConfig.db_type">
|
||||
<span class="sig-name descname"><span class="pre">db_type</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Literal" title="(in Python v3.13)"><span class="pre">Literal</span></a><span class="p"><span class="pre">[</span></span><span class="s"><span class="pre">'sqlite'</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="s"><span class="pre">'mem'</span></span><span class="p"><span class="pre">]</span></span></em><a class="headerlink" href="#searx.favicons.cache.FaviconCacheConfig.db_type" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Type of the database:</p>
|
||||
<dl class="simple">
|
||||
<dt><code class="docutils literal notranslate"><span class="pre">sqlite</span></code>:</dt><dd><p><a class="reference internal" href="#searx.favicons.cache.FaviconCacheSQLite" title="searx.favicons.cache.FaviconCacheSQLite"><code class="xref py py-obj docutils literal notranslate"><span class="pre">cache.FaviconCacheSQLite</span></code></a></p>
|
||||
</dd>
|
||||
<dt><code class="docutils literal notranslate"><span class="pre">mem</span></code>:</dt><dd><p><a class="reference internal" href="#searx.favicons.cache.FaviconCacheMEM" title="searx.favicons.cache.FaviconCacheMEM"><code class="xref py py-obj docutils literal notranslate"><span class="pre">cache.FaviconCacheMEM</span></code></a> (not recommended)</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py attribute">
|
||||
<dt class="sig sig-object py" id="searx.favicons.cache.FaviconCacheConfig.db_url">
|
||||
<span class="sig-name descname"><span class="pre">db_url</span></span><em class="property"><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></em><a class="headerlink" href="#searx.favicons.cache.FaviconCacheConfig.db_url" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>URL of the SQLite DB, the path to the database file.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py attribute">
|
||||
<dt class="sig sig-object py" id="searx.favicons.cache.FaviconCacheConfig.HOLD_TIME">
|
||||
<span class="sig-name descname"><span class="pre">HOLD_TIME</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><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></em><a class="headerlink" href="#searx.favicons.cache.FaviconCacheConfig.HOLD_TIME" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Hold time (default in sec.), after which a BLOB is removed from the cache.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py attribute">
|
||||
<dt class="sig sig-object py" id="searx.favicons.cache.FaviconCacheConfig.LIMIT_TOTAL_BYTES">
|
||||
<span class="sig-name descname"><span class="pre">LIMIT_TOTAL_BYTES</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><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></em><a class="headerlink" href="#searx.favicons.cache.FaviconCacheConfig.LIMIT_TOTAL_BYTES" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Maximum of bytes (default) stored in the cache of all blobs. Note: The
|
||||
limit is only reached at each maintenance interval after which the oldest
|
||||
BLOBs are deleted; the limit is exceeded during the maintenance period. If
|
||||
the maintenance period is <em>too long</em> or maintenance is switched off
|
||||
completely, the cache grows uncontrollably.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py attribute">
|
||||
<dt class="sig sig-object py" id="searx.favicons.cache.FaviconCacheConfig.BLOB_MAX_BYTES">
|
||||
<span class="sig-name descname"><span class="pre">BLOB_MAX_BYTES</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><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></em><a class="headerlink" href="#searx.favicons.cache.FaviconCacheConfig.BLOB_MAX_BYTES" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>The maximum BLOB size in bytes that a favicon may have so that it can be
|
||||
saved in the cache. If the favicon is larger, it is not saved in the cache
|
||||
and must be requested by the client via the proxy.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py attribute">
|
||||
<dt class="sig sig-object py" id="searx.favicons.cache.FaviconCacheConfig.MAINTENANCE_PERIOD">
|
||||
<span class="sig-name descname"><span class="pre">MAINTENANCE_PERIOD</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><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></em><a class="headerlink" href="#searx.favicons.cache.FaviconCacheConfig.MAINTENANCE_PERIOD" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Maintenance period in seconds / when <a class="reference internal" href="#searx.favicons.cache.FaviconCacheConfig.MAINTENANCE_MODE" title="searx.favicons.cache.FaviconCacheConfig.MAINTENANCE_MODE"><code class="xref py py-obj docutils literal notranslate"><span class="pre">MAINTENANCE_MODE</span></code></a> is set to
|
||||
<code class="docutils literal notranslate"><span class="pre">auto</span></code>.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py attribute">
|
||||
<dt class="sig sig-object py" id="searx.favicons.cache.FaviconCacheConfig.MAINTENANCE_MODE">
|
||||
<span class="sig-name descname"><span class="pre">MAINTENANCE_MODE</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Literal" title="(in Python v3.13)"><span class="pre">Literal</span></a><span class="p"><span class="pre">[</span></span><span class="s"><span class="pre">'auto'</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="s"><span class="pre">'off'</span></span><span class="p"><span class="pre">]</span></span></em><a class="headerlink" href="#searx.favicons.cache.FaviconCacheConfig.MAINTENANCE_MODE" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Type of maintenance mode</p>
|
||||
<dl class="simple">
|
||||
<dt><code class="docutils literal notranslate"><span class="pre">auto</span></code>:</dt><dd><p>Maintenance is carried out automatically as part of the maintenance
|
||||
intervals (<a class="reference internal" href="#searx.favicons.cache.FaviconCacheConfig.MAINTENANCE_PERIOD" title="searx.favicons.cache.FaviconCacheConfig.MAINTENANCE_PERIOD"><code class="xref py py-obj docutils literal notranslate"><span class="pre">MAINTENANCE_PERIOD</span></code></a>); no external process is required.</p>
|
||||
</dd>
|
||||
<dt><code class="docutils literal notranslate"><span class="pre">off</span></code>:</dt><dd><p>Maintenance is switched off and must be carried out by an external process
|
||||
if required.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py class">
|
||||
<dt class="sig sig-object py" id="searx.favicons.cache.FaviconCacheStats">
|
||||
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">searx.favicons.cache.</span></span><span class="sig-name descname"><span class="pre">FaviconCacheStats</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">favicons</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>, <em class="sig-param"><span class="n"><span class="pre">bytes</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>, <em class="sig-param"><span class="n"><span class="pre">domains</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>, <em class="sig-param"><span class="n"><span class="pre">resolvers</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/favicons/cache.html#FaviconCacheStats"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.cache.FaviconCacheStats" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Dataclass wich provides information on the status of the cache.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py class">
|
||||
<dt class="sig sig-object py" id="searx.favicons.cache.FaviconCache">
|
||||
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">searx.favicons.cache.</span></span><span class="sig-name descname"><span class="pre">FaviconCache</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cfg</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="#searx.favicons.cache.FaviconCacheConfig" title="searx.favicons.cache.FaviconCacheConfig"><span class="pre">FaviconCacheConfig</span></a></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/favicons/cache.html#FaviconCache"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.cache.FaviconCache" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Abstract base class for the implementation of a favicon cache.</p>
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.favicons.cache.FaviconCache.set">
|
||||
<em class="property"><span class="pre">abstract</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">set</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">resolver</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">authority</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">mime</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></em>, <em class="sig-param"><span class="n"><span class="pre">data</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#bytes" title="(in Python v3.13)"><span class="pre">bytes</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></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><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><a class="reference internal" href="../_modules/searx/favicons/cache.html#FaviconCache.set"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.cache.FaviconCache.set" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Set data and mime-type in the cache. If data is None, the
|
||||
<code class="xref py py-obj docutils literal notranslate"><span class="pre">FALLBACK_ICON</span></code> is registered. in the cache.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.favicons.cache.FaviconCache.state">
|
||||
<em class="property"><span class="pre">abstract</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">state</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><a class="reference internal" href="#searx.favicons.cache.FaviconCacheStats" title="searx.favicons.cache.FaviconCacheStats"><span class="pre">FaviconCacheStats</span></a></span></span><a class="reference internal" href="../_modules/searx/favicons/cache.html#FaviconCache.state"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.cache.FaviconCache.state" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Returns a <a class="reference internal" href="#searx.favicons.cache.FaviconCacheStats" title="searx.favicons.cache.FaviconCacheStats"><code class="xref py py-obj docutils literal notranslate"><span class="pre">FaviconCacheStats</span></code></a> (key/values) with information
|
||||
on the state of the cache.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.favicons.cache.FaviconCache.maintenance">
|
||||
<em class="property"><span class="pre">abstract</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">maintenance</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">force</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/favicons/cache.html#FaviconCache.maintenance"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.cache.FaviconCache.maintenance" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Performs maintenance on the cache</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py class">
|
||||
<dt class="sig sig-object py" id="searx.favicons.cache.FaviconCacheNull">
|
||||
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">searx.favicons.cache.</span></span><span class="sig-name descname"><span class="pre">FaviconCacheNull</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cfg</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="#searx.favicons.cache.FaviconCacheConfig" title="searx.favicons.cache.FaviconCacheConfig"><span class="pre">FaviconCacheConfig</span></a></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/favicons/cache.html#FaviconCacheNull"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.cache.FaviconCacheNull" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>A dummy favicon cache that caches nothing / a fallback solution. The
|
||||
NullCache is used when more efficient caches such as the
|
||||
<a class="reference internal" href="#searx.favicons.cache.FaviconCacheSQLite" title="searx.favicons.cache.FaviconCacheSQLite"><code class="xref py py-obj docutils literal notranslate"><span class="pre">FaviconCacheSQLite</span></code></a> cannot be used because, for example, the SQLite
|
||||
library is only available in an old version and does not meet the
|
||||
requirements.</p>
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.favicons.cache.FaviconCacheNull.set">
|
||||
<span class="sig-name descname"><span class="pre">set</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">resolver</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">authority</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">mime</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></em>, <em class="sig-param"><span class="n"><span class="pre">data</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#bytes" title="(in Python v3.13)"><span class="pre">bytes</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></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><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><a class="reference internal" href="../_modules/searx/favicons/cache.html#FaviconCacheNull.set"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.cache.FaviconCacheNull.set" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Set data and mime-type in the cache. If data is None, the
|
||||
<code class="xref py py-obj docutils literal notranslate"><span class="pre">FALLBACK_ICON</span></code> is registered. in the cache.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.favicons.cache.FaviconCacheNull.state">
|
||||
<span class="sig-name descname"><span class="pre">state</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/favicons/cache.html#FaviconCacheNull.state"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.cache.FaviconCacheNull.state" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Returns a <a class="reference internal" href="#searx.favicons.cache.FaviconCacheStats" title="searx.favicons.cache.FaviconCacheStats"><code class="xref py py-obj docutils literal notranslate"><span class="pre">FaviconCacheStats</span></code></a> (key/values) with information
|
||||
on the state of the cache.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.favicons.cache.FaviconCacheNull.maintenance">
|
||||
<span class="sig-name descname"><span class="pre">maintenance</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">force</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/favicons/cache.html#FaviconCacheNull.maintenance"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.cache.FaviconCacheNull.maintenance" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Performs maintenance on the cache</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py class">
|
||||
<dt class="sig sig-object py" id="searx.favicons.cache.FaviconCacheSQLite">
|
||||
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">searx.favicons.cache.</span></span><span class="sig-name descname"><span class="pre">FaviconCacheSQLite</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cfg</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="#searx.favicons.cache.FaviconCacheConfig" title="searx.favicons.cache.FaviconCacheConfig"><span class="pre">FaviconCacheConfig</span></a></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/favicons/cache.html#FaviconCacheSQLite"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.cache.FaviconCacheSQLite" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Favicon cache that manages the favicon BLOBs in a SQLite DB. The DB
|
||||
model in the SQLite DB is implemented using the abstract class
|
||||
<code class="xref py py-obj docutils literal notranslate"><span class="pre">sqlitedb.SQLiteAppl</span></code>.</p>
|
||||
<p>The following configurations are required / supported:</p>
|
||||
<ul class="simple">
|
||||
<li><p><a class="reference internal" href="#searx.favicons.cache.FaviconCacheConfig.db_url" title="searx.favicons.cache.FaviconCacheConfig.db_url"><code class="xref py py-obj docutils literal notranslate"><span class="pre">FaviconCacheConfig.db_url</span></code></a></p></li>
|
||||
<li><p><a class="reference internal" href="#searx.favicons.cache.FaviconCacheConfig.HOLD_TIME" title="searx.favicons.cache.FaviconCacheConfig.HOLD_TIME"><code class="xref py py-obj docutils literal notranslate"><span class="pre">FaviconCacheConfig.HOLD_TIME</span></code></a></p></li>
|
||||
<li><p><a class="reference internal" href="#searx.favicons.cache.FaviconCacheConfig.LIMIT_TOTAL_BYTES" title="searx.favicons.cache.FaviconCacheConfig.LIMIT_TOTAL_BYTES"><code class="xref py py-obj docutils literal notranslate"><span class="pre">FaviconCacheConfig.LIMIT_TOTAL_BYTES</span></code></a></p></li>
|
||||
<li><p><a class="reference internal" href="#searx.favicons.cache.FaviconCacheConfig.BLOB_MAX_BYTES" title="searx.favicons.cache.FaviconCacheConfig.BLOB_MAX_BYTES"><code class="xref py py-obj docutils literal notranslate"><span class="pre">FaviconCacheConfig.BLOB_MAX_BYTES</span></code></a></p></li>
|
||||
<li><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">MAINTENANCE_PERIOD</span></code></p></li>
|
||||
<li><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">MAINTENANCE_MODE</span></code></p></li>
|
||||
</ul>
|
||||
<dl class="py attribute">
|
||||
<dt class="sig sig-object py" id="searx.favicons.cache.FaviconCacheSQLite.DB_SCHEMA">
|
||||
<span class="sig-name descname"><span class="pre">DB_SCHEMA</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><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></em><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">1</span></em><a class="headerlink" href="#searx.favicons.cache.FaviconCacheSQLite.DB_SCHEMA" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>As soon as changes are made to the DB schema, the version number must be
|
||||
increased. Changes to the version number require the DB to be recreated (or
|
||||
migrated / if an migration path exists and is implemented).</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py attribute">
|
||||
<dt class="sig sig-object py" id="searx.favicons.cache.FaviconCacheSQLite.DDL_BLOBS">
|
||||
<span class="sig-name descname"><span class="pre">DDL_BLOBS</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">'CREATE</span> <span class="pre">TABLE</span> <span class="pre">IF</span> <span class="pre">NOT</span> <span class="pre">EXISTS</span> <span class="pre">blobs</span> <span class="pre">(\n</span>  <span class="pre">sha256</span>     <span class="pre">TEXT,\n</span>  <span class="pre">bytes_c</span>    <span class="pre">INTEGER,\n</span>  <span class="pre">mime</span>       <span class="pre">TEXT</span> <span class="pre">NOT</span> <span class="pre">NULL,\n</span>  <span class="pre">data</span>       <span class="pre">BLOB</span> <span class="pre">NOT</span> <span class="pre">NULL,\n</span>  <span class="pre">PRIMARY</span> <span class="pre">KEY</span> <span class="pre">(sha256))'</span></em><a class="headerlink" href="#searx.favicons.cache.FaviconCacheSQLite.DDL_BLOBS" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Table to store BLOB objects by their sha256 hash values.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py attribute">
|
||||
<dt class="sig sig-object py" id="searx.favicons.cache.FaviconCacheSQLite.DDL_BLOB_MAP">
|
||||
<span class="sig-name descname"><span class="pre">DDL_BLOB_MAP</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">"CREATE</span> <span class="pre">TABLE</span> <span class="pre">IF</span> <span class="pre">NOT</span> <span class="pre">EXISTS</span> <span class="pre">blob_map</span> <span class="pre">(\n</span>    <span class="pre">m_time</span>     <span class="pre">INTEGER</span> <span class="pre">DEFAULT</span> <span class="pre">(strftime('%s',</span> <span class="pre">'now')),</span>  <span class="pre">--</span> <span class="pre">last</span> <span class="pre">modified</span> <span class="pre">(unix</span> <span class="pre">epoch)</span> <span class="pre">time</span> <span class="pre">in</span> <span class="pre">sec.\n</span>    <span class="pre">sha256</span>     <span class="pre">TEXT,\n</span>    <span class="pre">resolver</span>   <span class="pre">TEXT,\n</span>    <span class="pre">authority</span>  <span class="pre">TEXT,\n</span>    <span class="pre">PRIMARY</span> <span class="pre">KEY</span> <span class="pre">(resolver,</span> <span class="pre">authority))"</span></em><a class="headerlink" href="#searx.favicons.cache.FaviconCacheSQLite.DDL_BLOB_MAP" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Table to map from (resolver, authority) to sha256 hash values.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py attribute">
|
||||
<dt class="sig sig-object py" id="searx.favicons.cache.FaviconCacheSQLite.SQL_DROP_LEFTOVER_BLOBS">
|
||||
<span class="sig-name descname"><span class="pre">SQL_DROP_LEFTOVER_BLOBS</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">'DELETE</span> <span class="pre">FROM</span> <span class="pre">blobs</span> <span class="pre">WHERE</span> <span class="pre">sha256</span> <span class="pre">IN</span> <span class="pre">(</span> <span class="pre">SELECT</span> <span class="pre">b.sha256</span>   <span class="pre">FROM</span> <span class="pre">blobs</span> <span class="pre">b</span>   <span class="pre">LEFT</span> <span class="pre">JOIN</span> <span class="pre">blob_map</span> <span class="pre">bm</span>     <span class="pre">ON</span> <span class="pre">b.sha256</span> <span class="pre">=</span> <span class="pre">bm.sha256</span>  <span class="pre">WHERE</span> <span class="pre">bm.sha256</span> <span class="pre">IS</span> <span class="pre">NULL)'</span></em><a class="headerlink" href="#searx.favicons.cache.FaviconCacheSQLite.SQL_DROP_LEFTOVER_BLOBS" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Delete blobs.sha256 (BLOBs) no longer in blob_map.sha256.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.favicons.cache.FaviconCacheSQLite.set">
|
||||
<span class="sig-name descname"><span class="pre">set</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">resolver</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">authority</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">mime</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></em>, <em class="sig-param"><span class="n"><span class="pre">data</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#bytes" title="(in Python v3.13)"><span class="pre">bytes</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></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><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><a class="reference internal" href="../_modules/searx/favicons/cache.html#FaviconCacheSQLite.set"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.cache.FaviconCacheSQLite.set" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Set data and mime-type in the cache. If data is None, the
|
||||
<code class="xref py py-obj docutils literal notranslate"><span class="pre">FALLBACK_ICON</span></code> is registered. in the cache.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py property">
|
||||
<dt class="sig sig-object py" id="searx.favicons.cache.FaviconCacheSQLite.next_maintenance_time">
|
||||
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">next_maintenance_time</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><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></em><a class="headerlink" href="#searx.favicons.cache.FaviconCacheSQLite.next_maintenance_time" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Returns (unix epoch) time of the next maintenance.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.favicons.cache.FaviconCacheSQLite.maintenance">
|
||||
<span class="sig-name descname"><span class="pre">maintenance</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">force</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/favicons/cache.html#FaviconCacheSQLite.maintenance"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.cache.FaviconCacheSQLite.maintenance" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Performs maintenance on the cache</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.favicons.cache.FaviconCacheSQLite.state">
|
||||
<span class="sig-name descname"><span class="pre">state</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><a class="reference internal" href="#searx.favicons.cache.FaviconCacheStats" title="searx.favicons.cache.FaviconCacheStats"><span class="pre">FaviconCacheStats</span></a></span></span><a class="reference internal" href="../_modules/searx/favicons/cache.html#FaviconCacheSQLite.state"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.cache.FaviconCacheSQLite.state" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Returns a <a class="reference internal" href="#searx.favicons.cache.FaviconCacheStats" title="searx.favicons.cache.FaviconCacheStats"><code class="xref py py-obj docutils literal notranslate"><span class="pre">FaviconCacheStats</span></code></a> (key/values) with information
|
||||
on the state of the cache.</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py class">
|
||||
<dt class="sig sig-object py" id="searx.favicons.cache.FaviconCacheMEM">
|
||||
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">searx.favicons.cache.</span></span><span class="sig-name descname"><span class="pre">FaviconCacheMEM</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cfg</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/favicons/cache.html#FaviconCacheMEM"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.cache.FaviconCacheMEM" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Favicon cache in process’ memory. Its just a POC that stores the
|
||||
favicons in the memory of the process.</p>
|
||||
<div class="admonition attention">
|
||||
<p class="admonition-title">Attention</p>
|
||||
<p>Don’t use it in production, it will blow up your memory!!</p>
|
||||
</div>
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.favicons.cache.FaviconCacheMEM.set">
|
||||
<span class="sig-name descname"><span class="pre">set</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">resolver</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">authority</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">mime</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></em>, <em class="sig-param"><span class="n"><span class="pre">data</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#bytes" title="(in Python v3.13)"><span class="pre">bytes</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></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><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><a class="reference internal" href="../_modules/searx/favicons/cache.html#FaviconCacheMEM.set"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.cache.FaviconCacheMEM.set" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Set data and mime-type in the cache. If data is None, the
|
||||
<code class="xref py py-obj docutils literal notranslate"><span class="pre">FALLBACK_ICON</span></code> is registered. in the cache.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.favicons.cache.FaviconCacheMEM.state">
|
||||
<span class="sig-name descname"><span class="pre">state</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/favicons/cache.html#FaviconCacheMEM.state"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.cache.FaviconCacheMEM.state" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Returns a <a class="reference internal" href="#searx.favicons.cache.FaviconCacheStats" title="searx.favicons.cache.FaviconCacheStats"><code class="xref py py-obj docutils literal notranslate"><span class="pre">FaviconCacheStats</span></code></a> (key/values) with information
|
||||
on the state of the cache.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.favicons.cache.FaviconCacheMEM.maintenance">
|
||||
<span class="sig-name descname"><span class="pre">maintenance</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">force</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/favicons/cache.html#FaviconCacheMEM.maintenance"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.favicons.cache.FaviconCacheMEM.maintenance" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Performs maintenance on the cache</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd></dl>
|
||||
|
||||
</section>
|
||||
</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 current"><a class="current reference internal" href="#">Favicons (source)</a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.favicons.favicon_url"><code class="docutils literal notranslate"><span class="pre">favicon_url()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.favicons.favicon_proxy"><code class="docutils literal notranslate"><span class="pre">favicon_proxy()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#module-searx.favicons.config">Favicons Config</a><ul>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.favicons.config.CONFIG_SCHEMA"><code class="docutils literal notranslate"><span class="pre">CONFIG_SCHEMA</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.favicons.config.TOML_CACHE_CFG"><code class="docutils literal notranslate"><span class="pre">TOML_CACHE_CFG</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.favicons.config.FaviconConfig"><code class="docutils literal notranslate"><span class="pre">FaviconConfig</span></code></a><ul>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.favicons.config.FaviconConfig.cfg_schema"><code class="docutils literal notranslate"><span class="pre">FaviconConfig.cfg_schema</span></code></a></li>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.favicons.config.FaviconConfig.cache"><code class="docutils literal notranslate"><span class="pre">FaviconConfig.cache</span></code></a></li>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.favicons.config.FaviconConfig.proxy"><code class="docutils literal notranslate"><span class="pre">FaviconConfig.proxy</span></code></a></li>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.favicons.config.FaviconConfig.from_toml_file"><code class="docutils literal notranslate"><span class="pre">FaviconConfig.from_toml_file()</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#module-searx.favicons.proxy">Favicons Proxy</a><ul>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.favicons.proxy.FaviconProxyConfig"><code class="docutils literal notranslate"><span class="pre">FaviconProxyConfig</span></code></a><ul>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.favicons.proxy.FaviconProxyConfig.max_age"><code class="docutils literal notranslate"><span class="pre">FaviconProxyConfig.max_age</span></code></a></li>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.favicons.proxy.FaviconProxyConfig.secret_key"><code class="docutils literal notranslate"><span class="pre">FaviconProxyConfig.secret_key</span></code></a></li>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.favicons.proxy.FaviconProxyConfig.resolver_timeout"><code class="docutils literal notranslate"><span class="pre">FaviconProxyConfig.resolver_timeout</span></code></a></li>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.favicons.proxy.FaviconProxyConfig.resolver_map"><code class="docutils literal notranslate"><span class="pre">FaviconProxyConfig.resolver_map</span></code></a></li>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.favicons.proxy.FaviconProxyConfig.get_resolver"><code class="docutils literal notranslate"><span class="pre">FaviconProxyConfig.get_resolver()</span></code></a></li>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.favicons.proxy.FaviconProxyConfig.favicon"><code class="docutils literal notranslate"><span class="pre">FaviconProxyConfig.favicon()</span></code></a></li>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.favicons.proxy.FaviconProxyConfig.favicon_data_url"><code class="docutils literal notranslate"><span class="pre">FaviconProxyConfig.favicon_data_url()</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.favicons.proxy.favicon_proxy"><code class="docutils literal notranslate"><span class="pre">favicon_proxy()</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.favicons.proxy.search_favicon"><code class="docutils literal notranslate"><span class="pre">search_favicon()</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.favicons.proxy.favicon_url"><code class="docutils literal notranslate"><span class="pre">favicon_url()</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#module-searx.favicons.resolvers">Favicons Resolver</a><ul>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.favicons.resolvers.allesedv"><code class="docutils literal notranslate"><span class="pre">allesedv()</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.favicons.resolvers.duckduckgo"><code class="docutils literal notranslate"><span class="pre">duckduckgo()</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.favicons.resolvers.google"><code class="docutils literal notranslate"><span class="pre">google()</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.favicons.resolvers.yandex"><code class="docutils literal notranslate"><span class="pre">yandex()</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#module-searx.favicons.cache">Favicons Cache</a><ul>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.favicons.cache.state"><code class="docutils literal notranslate"><span class="pre">state()</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.favicons.cache.maintenance"><code class="docutils literal notranslate"><span class="pre">maintenance()</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.favicons.cache.init"><code class="docutils literal notranslate"><span class="pre">init()</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.favicons.cache.FaviconCacheConfig"><code class="docutils literal notranslate"><span class="pre">FaviconCacheConfig</span></code></a><ul>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.favicons.cache.FaviconCacheConfig.db_type"><code class="docutils literal notranslate"><span class="pre">FaviconCacheConfig.db_type</span></code></a></li>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.favicons.cache.FaviconCacheConfig.db_url"><code class="docutils literal notranslate"><span class="pre">FaviconCacheConfig.db_url</span></code></a></li>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.favicons.cache.FaviconCacheConfig.HOLD_TIME"><code class="docutils literal notranslate"><span class="pre">FaviconCacheConfig.HOLD_TIME</span></code></a></li>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.favicons.cache.FaviconCacheConfig.LIMIT_TOTAL_BYTES"><code class="docutils literal notranslate"><span class="pre">FaviconCacheConfig.LIMIT_TOTAL_BYTES</span></code></a></li>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.favicons.cache.FaviconCacheConfig.BLOB_MAX_BYTES"><code class="docutils literal notranslate"><span class="pre">FaviconCacheConfig.BLOB_MAX_BYTES</span></code></a></li>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.favicons.cache.FaviconCacheConfig.MAINTENANCE_PERIOD"><code class="docutils literal notranslate"><span class="pre">FaviconCacheConfig.MAINTENANCE_PERIOD</span></code></a></li>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.favicons.cache.FaviconCacheConfig.MAINTENANCE_MODE"><code class="docutils literal notranslate"><span class="pre">FaviconCacheConfig.MAINTENANCE_MODE</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.favicons.cache.FaviconCacheStats"><code class="docutils literal notranslate"><span class="pre">FaviconCacheStats</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.favicons.cache.FaviconCache"><code class="docutils literal notranslate"><span class="pre">FaviconCache</span></code></a><ul>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.favicons.cache.FaviconCache.set"><code class="docutils literal notranslate"><span class="pre">FaviconCache.set()</span></code></a></li>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.favicons.cache.FaviconCache.state"><code class="docutils literal notranslate"><span class="pre">FaviconCache.state()</span></code></a></li>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.favicons.cache.FaviconCache.maintenance"><code class="docutils literal notranslate"><span class="pre">FaviconCache.maintenance()</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.favicons.cache.FaviconCacheNull"><code class="docutils literal notranslate"><span class="pre">FaviconCacheNull</span></code></a><ul>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.favicons.cache.FaviconCacheNull.set"><code class="docutils literal notranslate"><span class="pre">FaviconCacheNull.set()</span></code></a></li>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.favicons.cache.FaviconCacheNull.state"><code class="docutils literal notranslate"><span class="pre">FaviconCacheNull.state()</span></code></a></li>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.favicons.cache.FaviconCacheNull.maintenance"><code class="docutils literal notranslate"><span class="pre">FaviconCacheNull.maintenance()</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.favicons.cache.FaviconCacheSQLite"><code class="docutils literal notranslate"><span class="pre">FaviconCacheSQLite</span></code></a><ul>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.favicons.cache.FaviconCacheSQLite.DB_SCHEMA"><code class="docutils literal notranslate"><span class="pre">FaviconCacheSQLite.DB_SCHEMA</span></code></a></li>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.favicons.cache.FaviconCacheSQLite.DDL_BLOBS"><code class="docutils literal notranslate"><span class="pre">FaviconCacheSQLite.DDL_BLOBS</span></code></a></li>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.favicons.cache.FaviconCacheSQLite.DDL_BLOB_MAP"><code class="docutils literal notranslate"><span class="pre">FaviconCacheSQLite.DDL_BLOB_MAP</span></code></a></li>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.favicons.cache.FaviconCacheSQLite.SQL_DROP_LEFTOVER_BLOBS"><code class="docutils literal notranslate"><span class="pre">FaviconCacheSQLite.SQL_DROP_LEFTOVER_BLOBS</span></code></a></li>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.favicons.cache.FaviconCacheSQLite.set"><code class="docutils literal notranslate"><span class="pre">FaviconCacheSQLite.set()</span></code></a></li>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.favicons.cache.FaviconCacheSQLite.next_maintenance_time"><code class="docutils literal notranslate"><span class="pre">FaviconCacheSQLite.next_maintenance_time</span></code></a></li>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.favicons.cache.FaviconCacheSQLite.maintenance"><code class="docutils literal notranslate"><span class="pre">FaviconCacheSQLite.maintenance()</span></code></a></li>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.favicons.cache.FaviconCacheSQLite.state"><code class="docutils literal notranslate"><span class="pre">FaviconCacheSQLite.state()</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.favicons.cache.FaviconCacheMEM"><code class="docutils literal notranslate"><span class="pre">FaviconCacheMEM</span></code></a><ul>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.favicons.cache.FaviconCacheMEM.set"><code class="docutils literal notranslate"><span class="pre">FaviconCacheMEM.set()</span></code></a></li>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.favicons.cache.FaviconCacheMEM.state"><code class="docutils literal notranslate"><span class="pre">FaviconCacheMEM.state()</span></code></a></li>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.favicons.cache.FaviconCacheMEM.maintenance"><code class="docutils literal notranslate"><span class="pre">FaviconCacheMEM.maintenance()</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</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.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"><a class="reference internal" href="searx.utils.html">Utility functions for the engines</a></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.exceptions.html" title="previous chapter">SearXNG Exceptions</a>
|
||||
<li>Next: <a href="searx.infopage.html" title="next chapter">Online <code class="docutils literal notranslate"><span class="pre">/info</span></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 role="note" aria-label="source link">
|
||||
<h3>This Page</h3>
|
||||
<ul class="this-page-menu">
|
||||
<li><a href="../_sources/src/searx.favicons.rst.txt"
|
||||
rel="nofollow">Show Source</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright SearXNG team.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
264
src/searx.infopage.html
Normal file
264
src/searx.infopage.html
Normal file
@@ -0,0 +1,264 @@
|
||||
<!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>Online /info — SearXNG Documentation (2025.4.11+2287a6826)</title>
|
||||
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=6625fa76" />
|
||||
<link rel="stylesheet" type="text/css" href="../_static/searxng.css?v=52e4ff28" />
|
||||
<script src="../_static/documentation_options.js?v=725693a2"></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.4.11+2287a6826" 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="next" title="Locales" href="searx.locales.html" />
|
||||
<link rel="prev" title="Favicons (source)" href="searx.favicons.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.locales.html" title="Locales"
|
||||
accesskey="N">next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="searx.favicons.html" title="Favicons (source)"
|
||||
accesskey="P">previous</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../index.html">SearXNG Documentation (2025.4.11+2287a6826)</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Source-Code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">Online <code class="docutils literal notranslate"><span class="pre">/info</span></code></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<section id="module-searx.infopage">
|
||||
<span id="online-info"></span><span id="searx-infopage"></span><h1>Online <code class="docutils literal notranslate"><span class="pre">/info</span></code><a class="headerlink" href="#module-searx.infopage" title="Link to this heading">¶</a></h1>
|
||||
<p>Render SearXNG instance documentation.</p>
|
||||
<p>Usage in a Flask app route:</p>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span><span class="w"> </span><span class="nn">searx</span><span class="w"> </span><span class="kn">import</span> <span class="n">infopage</span>
|
||||
<span class="kn">from</span><span class="w"> </span><span class="nn">searx.extended_types</span><span class="w"> </span><span class="kn">import</span> <span class="n">sxng_request</span>
|
||||
|
||||
<span class="n">_INFO_PAGES</span> <span class="o">=</span> <span class="n">infopage</span><span class="o">.</span><span class="n">InfoPageSet</span><span class="p">(</span><span class="n">infopage</span><span class="o">.</span><span class="n">MistletoePage</span><span class="p">)</span>
|
||||
|
||||
<span class="nd">@app</span><span class="o">.</span><span class="n">route</span><span class="p">(</span><span class="s1">'/info/<pagename>'</span><span class="p">,</span> <span class="n">methods</span><span class="o">=</span><span class="p">[</span><span class="s1">'GET'</span><span class="p">])</span>
|
||||
<span class="k">def</span><span class="w"> </span><span class="nf">info</span><span class="p">(</span><span class="n">pagename</span><span class="p">):</span>
|
||||
|
||||
<span class="n">locale</span> <span class="o">=</span> <span class="n">sxng_request</span><span class="o">.</span><span class="n">preferences</span><span class="o">.</span><span class="n">get_value</span><span class="p">(</span><span class="s1">'locale'</span><span class="p">)</span>
|
||||
<span class="n">page</span> <span class="o">=</span> <span class="n">_INFO_PAGES</span><span class="o">.</span><span class="n">get_page</span><span class="p">(</span><span class="n">pagename</span><span class="p">,</span> <span class="n">locale</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<dl class="py class">
|
||||
<dt class="sig sig-object py" id="searx.infopage.InfoPage">
|
||||
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">searx.infopage.</span></span><span class="sig-name descname"><span class="pre">InfoPage</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fname</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/infopage.html#InfoPage"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.infopage.InfoPage" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>A page of the <a class="reference internal" href="#searx.infopage.InfoPageSet" title="searx.infopage.InfoPageSet"><code class="xref py py-obj docutils literal notranslate"><span class="pre">online</span> <span class="pre">documentation</span></code></a>.</p>
|
||||
<dl class="py property">
|
||||
<dt class="sig sig-object py" id="searx.infopage.InfoPage.raw_content">
|
||||
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">raw_content</span></span><a class="headerlink" href="#searx.infopage.InfoPage.raw_content" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Raw content of the page (without any jinja rendering)</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py property">
|
||||
<dt class="sig sig-object py" id="searx.infopage.InfoPage.content">
|
||||
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">content</span></span><a class="headerlink" href="#searx.infopage.InfoPage.content" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Content of the page (rendered in a Jinja context)</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py property">
|
||||
<dt class="sig sig-object py" id="searx.infopage.InfoPage.title">
|
||||
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">title</span></span><a class="headerlink" href="#searx.infopage.InfoPage.title" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Title of the content (without any markup)</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py property">
|
||||
<dt class="sig sig-object py" id="searx.infopage.InfoPage.html">
|
||||
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">html</span></span><a class="headerlink" href="#searx.infopage.InfoPage.html" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Render Markdown (<a class="reference external" href="https://commonmark.org/">CommonMark</a>) to HTML by using <a class="reference external" href="https://github.com/executablebooks/markdown-it-py">markdown-it-py</a>.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.infopage.InfoPage.get_ctx">
|
||||
<span class="sig-name descname"><span class="pre">get_ctx</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/infopage.html#InfoPage.get_ctx"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.infopage.InfoPage.get_ctx" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Jinja context to render <a class="reference internal" href="#searx.infopage.InfoPage.content" title="searx.infopage.InfoPage.content"><code class="xref py py-obj docutils literal notranslate"><span class="pre">InfoPage.content</span></code></a></p>
|
||||
</dd></dl>
|
||||
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py class">
|
||||
<dt class="sig sig-object py" id="searx.infopage.InfoPageSet">
|
||||
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">searx.infopage.</span></span><span class="sig-name descname"><span class="pre">InfoPageSet</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">page_class</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.Type" title="(in Python v3.13)"><span class="pre">Type</span></a><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#searx.infopage.InfoPage" title="searx.infopage.InfoPage"><span class="pre">InfoPage</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 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>, <em class="sig-param"><span class="n"><span class="pre">info_folder</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><a class="reference internal" href="../_modules/searx/infopage.html#InfoPageSet"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.infopage.InfoPageSet" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Cached rendering of the online documentation a SearXNG instance has.</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>page_class</strong> (<a class="reference internal" href="#searx.infopage.InfoPage" title="searx.infopage.InfoPage"><code class="xref py py-obj docutils literal notranslate"><span class="pre">InfoPage</span></code></a>) – render online documentation by <a class="reference internal" href="#searx.infopage.InfoPage" title="searx.infopage.InfoPage"><code class="xref py py-obj docutils literal notranslate"><span class="pre">InfoPage</span></code></a> parser.</p></li>
|
||||
<li><p><strong>info_folder</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><em>str</em></a>) – information directory</p></li>
|
||||
</ul>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="py attribute">
|
||||
<dt class="sig sig-object py" id="searx.infopage.InfoPageSet.folder">
|
||||
<span class="sig-name descname"><span class="pre">folder</span></span><em class="property"><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></em><a class="headerlink" href="#searx.infopage.InfoPageSet.folder" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>location of the Markdown files</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py attribute">
|
||||
<dt class="sig sig-object py" id="searx.infopage.InfoPageSet.locale_default">
|
||||
<span class="sig-name descname"><span class="pre">locale_default</span></span><em class="property"><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></em><a class="headerlink" href="#searx.infopage.InfoPageSet.locale_default" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>default language</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py attribute">
|
||||
<dt class="sig sig-object py" id="searx.infopage.InfoPageSet.locales">
|
||||
<span class="sig-name descname"><span class="pre">locales</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><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></em><a class="headerlink" href="#searx.infopage.InfoPageSet.locales" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>list of supported languages (aka locales)</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py attribute">
|
||||
<dt class="sig sig-object py" id="searx.infopage.InfoPageSet.toc">
|
||||
<span class="sig-name descname"><span class="pre">toc</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><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></em><a class="headerlink" href="#searx.infopage.InfoPageSet.toc" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>list of articles in the online documentation</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.infopage.InfoPageSet.get_page">
|
||||
<span class="sig-name descname"><span class="pre">get_page</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">pagename</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">locale</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><a class="reference internal" href="../_modules/searx/infopage.html#InfoPageSet.get_page"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.infopage.InfoPageSet.get_page" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Return <code class="docutils literal notranslate"><span class="pre">pagename</span></code> instance of <a class="reference internal" href="#searx.infopage.InfoPage" title="searx.infopage.InfoPage"><code class="xref py py-obj docutils literal notranslate"><span class="pre">InfoPage</span></code></a></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>pagename</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><em>str</em></a>) – name of the page, a value from <a class="reference internal" href="#searx.infopage.InfoPageSet.toc" title="searx.infopage.InfoPageSet.toc"><code class="xref py py-obj docutils literal notranslate"><span class="pre">InfoPageSet.toc</span></code></a></p></li>
|
||||
<li><p><strong>locale</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><em>str</em></a>) – language of the page, e.g. <code class="docutils literal notranslate"><span class="pre">en</span></code>, <code class="docutils literal notranslate"><span class="pre">zh_Hans_CN</span></code>
|
||||
(default: <code class="xref py py-obj docutils literal notranslate"><span class="pre">InfoPageSet.i18n_origin</span></code>)</p></li>
|
||||
</ul>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.infopage.InfoPageSet.iter_pages">
|
||||
<span class="sig-name descname"><span class="pre">iter_pages</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">locale</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>, <em class="sig-param"><span class="n"><span class="pre">fallback_to_default</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/infopage.html#InfoPageSet.iter_pages"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.infopage.InfoPageSet.iter_pages" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Iterate over all pages of the TOC</p>
|
||||
</dd></dl>
|
||||
|
||||
</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 current"><a class="current reference internal" href="#">Online <code class="docutils literal notranslate"><span class="pre">/info</span></code></a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.infopage.InfoPage"><code class="docutils literal notranslate"><span class="pre">InfoPage</span></code></a><ul>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.infopage.InfoPage.raw_content"><code class="docutils literal notranslate"><span class="pre">InfoPage.raw_content</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.infopage.InfoPage.content"><code class="docutils literal notranslate"><span class="pre">InfoPage.content</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.infopage.InfoPage.title"><code class="docutils literal notranslate"><span class="pre">InfoPage.title</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.infopage.InfoPage.html"><code class="docutils literal notranslate"><span class="pre">InfoPage.html</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.infopage.InfoPage.get_ctx"><code class="docutils literal notranslate"><span class="pre">InfoPage.get_ctx()</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.infopage.InfoPageSet"><code class="docutils literal notranslate"><span class="pre">InfoPageSet</span></code></a><ul>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.infopage.InfoPageSet.folder"><code class="docutils literal notranslate"><span class="pre">InfoPageSet.folder</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.infopage.InfoPageSet.locale_default"><code class="docutils literal notranslate"><span class="pre">InfoPageSet.locale_default</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.infopage.InfoPageSet.locales"><code class="docutils literal notranslate"><span class="pre">InfoPageSet.locales</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.infopage.InfoPageSet.toc"><code class="docutils literal notranslate"><span class="pre">InfoPageSet.toc</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.infopage.InfoPageSet.get_page"><code class="docutils literal notranslate"><span class="pre">InfoPageSet.get_page()</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.infopage.InfoPageSet.iter_pages"><code class="docutils literal notranslate"><span class="pre">InfoPageSet.iter_pages()</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</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.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"><a class="reference internal" href="searx.utils.html">Utility functions for the engines</a></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.favicons.html" title="previous chapter">Favicons (source)</a>
|
||||
<li>Next: <a href="searx.locales.html" title="next chapter">Locales</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.infopage.rst.txt"
|
||||
rel="nofollow">Show Source</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright SearXNG team.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
424
src/searx.locales.html
Normal file
424
src/searx.locales.html
Normal file
@@ -0,0 +1,424 @@
|
||||
<!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>Locales — SearXNG Documentation (2025.4.11+2287a6826)</title>
|
||||
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=6625fa76" />
|
||||
<link rel="stylesheet" type="text/css" href="../_static/searxng.css?v=52e4ff28" />
|
||||
<script src="../_static/documentation_options.js?v=725693a2"></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.4.11+2287a6826" 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="next" title="Redis DB" href="searx.redisdb.html" />
|
||||
<link rel="prev" title="Online /info" href="searx.infopage.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.redisdb.html" title="Redis DB"
|
||||
accesskey="N">next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="searx.infopage.html" title="Online /info"
|
||||
accesskey="P">previous</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../index.html">SearXNG Documentation (2025.4.11+2287a6826)</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Source-Code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">Locales</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<section id="locales">
|
||||
<span id="searx-locales"></span><h1>Locales<a class="headerlink" href="#locales" title="Link to this heading">¶</a></h1>
|
||||
<nav class="contents local" id="contents">
|
||||
<ul class="simple">
|
||||
<li><p><a class="reference internal" href="#searxngs-locale-data" id="id1">SearXNG’s locale data</a></p></li>
|
||||
<li><p><a class="reference internal" href="#module-searx.sxng_locales" id="id2">SearXNG’s locale codes</a></p></li>
|
||||
<li><p><a class="reference internal" href="#searxngs-locale-implementations" id="id3">SearXNG’s locale implementations</a></p></li>
|
||||
</ul>
|
||||
</nav>
|
||||
<section id="searxngs-locale-data">
|
||||
<span id="module-searx.locales"></span><h2><a class="toc-backref" href="#id1" role="doc-backlink">SearXNG’s locale data</a><a class="headerlink" href="#searxngs-locale-data" title="Link to this heading">¶</a></h2>
|
||||
<p>The variables <a class="reference internal" href="#searx.locales.RTL_LOCALES" title="searx.locales.RTL_LOCALES"><code class="xref py py-obj docutils literal notranslate"><span class="pre">RTL_LOCALES</span></code></a> and <a class="reference internal" href="#searx.locales.LOCALE_NAMES" title="searx.locales.LOCALE_NAMES"><code class="xref py py-obj docutils literal notranslate"><span class="pre">LOCALE_NAMES</span></code></a> are loaded from
|
||||
<a class="extlink-origin reference external" href="https://github.com/searxng/searxng/blob/master/searx/data/locales.json">git://searx/data/locales.json</a> / see <a class="reference internal" href="#searx.locales.locales_initialize" title="searx.locales.locales_initialize"><code class="xref py py-obj docutils literal notranslate"><span class="pre">locales_initialize</span></code></a> and
|
||||
<a class="reference internal" href="../dev/searxng_extra/update.html#update-locales-py"><span class="std std-ref">update_locales.py</span></a>.</p>
|
||||
<div class="admonition hint">
|
||||
<p class="admonition-title">Hint</p>
|
||||
<p>Whenever the value of <a class="reference internal" href="#searx.locales.ADDITIONAL_TRANSLATIONS" title="searx.locales.ADDITIONAL_TRANSLATIONS"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ADDITIONAL_TRANSLATIONS</span></code></a> or
|
||||
<a class="reference internal" href="#searx.locales.LOCALE_BEST_MATCH" title="searx.locales.LOCALE_BEST_MATCH"><code class="xref py py-obj docutils literal notranslate"><span class="pre">LOCALE_BEST_MATCH</span></code></a> is modified, the
|
||||
<a class="extlink-origin reference external" href="https://github.com/searxng/searxng/blob/master/searx/data/locales.json">git://searx/data/locales.json</a> needs to be rebuild:</p>
|
||||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">./</span><span class="n">manage</span> <span class="n">data</span><span class="o">.</span><span class="n">locales</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section id="module-searx.sxng_locales">
|
||||
<span id="searxng-s-locale-codes"></span><h2><a class="toc-backref" href="#id2" role="doc-backlink">SearXNG’s locale codes</a><a class="headerlink" href="#module-searx.sxng_locales" title="Link to this heading">¶</a></h2>
|
||||
<p>List of SearXNG’s locale codes used for the search language/region.</p>
|
||||
<div class="admonition hint">
|
||||
<p class="admonition-title">Hint</p>
|
||||
<p>Don’t modify this file, this file is generated by:</p>
|
||||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">./</span><span class="n">manage</span> <span class="n">data</span><span class="o">.</span><span class="n">traits</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
<dl class="py data">
|
||||
<dt class="sig sig-object py" id="searx.sxng_locales.sxng_locales">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.sxng_locales.</span></span><span class="sig-name descname"><span class="pre">sxng_locales</span></span><a class="headerlink" href="#searx.sxng_locales.sxng_locales" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>A list of five-digit tuples:</p>
|
||||
<ol class="arabic simple" start="0">
|
||||
<li><p>SearXNG’s internal locale tag (a language or region tag)</p></li>
|
||||
<li><p>Name of the language (<a class="reference external" href="https://babel.readthedocs.io/en/latest/api/core.html#babel.core.Locale.get_language_name" title="(in Babel v2.2)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">babel.core.Locale.get_language_name</span></code></a>)</p></li>
|
||||
<li><p>For region tags the name of the region (<a class="reference external" href="https://babel.readthedocs.io/en/latest/api/core.html#babel.core.Locale.get_territory_name" title="(in Babel v2.2)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">babel.core.Locale.get_territory_name</span></code></a>).
|
||||
Empty string for language tags.</p></li>
|
||||
<li><p>English language name (from <a class="reference external" href="https://babel.readthedocs.io/en/latest/api/core.html#babel.core.Locale.english_name" title="(in Babel v2.2)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">babel.core.Locale.english_name</span></code></a>)</p></li>
|
||||
<li><p>Unicode flag (emoji) that fits to SearXNG’s internal region tag. Languages
|
||||
are represented by a globe (🌐)</p></li>
|
||||
</ol>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="s1">'en'</span><span class="p">,</span> <span class="s1">'English'</span><span class="p">,</span> <span class="s1">''</span><span class="p">,</span> <span class="s1">'English'</span><span class="p">,</span> <span class="s1">'🌐'</span><span class="p">),</span>
|
||||
<span class="p">(</span><span class="s1">'en-CA'</span><span class="p">,</span> <span class="s1">'English'</span><span class="p">,</span> <span class="s1">'Canada'</span><span class="p">,</span> <span class="s1">'English'</span><span class="p">,</span> <span class="s1">'🇨🇦'</span><span class="p">),</span>
|
||||
<span class="p">(</span><span class="s1">'en-US'</span><span class="p">,</span> <span class="s1">'English'</span><span class="p">,</span> <span class="s1">'United States'</span><span class="p">,</span> <span class="s1">'English'</span><span class="p">,</span> <span class="s1">'🇺🇸'</span><span class="p">),</span>
|
||||
<span class="o">..</span>
|
||||
<span class="p">(</span><span class="s1">'fr'</span><span class="p">,</span> <span class="s1">'Français'</span><span class="p">,</span> <span class="s1">''</span><span class="p">,</span> <span class="s1">'French'</span><span class="p">,</span> <span class="s1">'🌐'</span><span class="p">),</span>
|
||||
<span class="p">(</span><span class="s1">'fr-BE'</span><span class="p">,</span> <span class="s1">'Français'</span><span class="p">,</span> <span class="s1">'Belgique'</span><span class="p">,</span> <span class="s1">'French'</span><span class="p">,</span> <span class="s1">'🇧🇪'</span><span class="p">),</span>
|
||||
<span class="p">(</span><span class="s1">'fr-CA'</span><span class="p">,</span> <span class="s1">'Français'</span><span class="p">,</span> <span class="s1">'Canada'</span><span class="p">,</span> <span class="s1">'French'</span><span class="p">,</span> <span class="s1">'🇨🇦'</span><span class="p">),</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<dl class="field-list simple">
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
</section>
|
||||
<section id="searxngs-locale-implementations">
|
||||
<h2><a class="toc-backref" href="#id3" role="doc-backlink">SearXNG’s locale implementations</a><a class="headerlink" href="#searxngs-locale-implementations" title="Link to this heading">¶</a></h2>
|
||||
</section>
|
||||
<dl class="py data">
|
||||
<dt class="sig sig-object py" id="searx.locales.LOCALE_NAMES">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.locales.</span></span><span class="sig-name descname"><span class="pre">LOCALE_NAMES</span></span><a class="headerlink" href="#searx.locales.LOCALE_NAMES" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Mapping of locales and their description. Locales e.g. ‘fr’ or ‘pt-BR’ (see
|
||||
<a class="reference internal" href="#searx.locales.locales_initialize" title="searx.locales.locales_initialize"><code class="xref py py-obj docutils literal notranslate"><span class="pre">locales_initialize</span></code></a>).</p>
|
||||
<dl class="field-list simple">
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py data">
|
||||
<dt class="sig sig-object py" id="searx.locales.RTL_LOCALES">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.locales.</span></span><span class="sig-name descname"><span class="pre">RTL_LOCALES</span></span><em class="property"><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#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></em><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">{'ar',</span> <span class="pre">'fa-IR',</span> <span class="pre">'he'}</span></em><a class="headerlink" href="#searx.locales.RTL_LOCALES" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>List of <em>Right-To-Left</em> locales e.g. ‘he’ or ‘fa-IR’ (see
|
||||
<a class="reference internal" href="#searx.locales.locales_initialize" title="searx.locales.locales_initialize"><code class="xref py py-obj docutils literal notranslate"><span class="pre">locales_initialize</span></code></a>).</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py data">
|
||||
<dt class="sig sig-object py" id="searx.locales.ADDITIONAL_TRANSLATIONS">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.locales.</span></span><span class="sig-name descname"><span class="pre">ADDITIONAL_TRANSLATIONS</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">{'dv':</span> <span class="pre">'ދިވެހި</span> <span class="pre">(Dhivehi)',</span> <span class="pre">'oc':</span> <span class="pre">'Occitan',</span> <span class="pre">'pap':</span> <span class="pre">'Papiamento',</span> <span class="pre">'szl':</span> <span class="pre">'Ślōnski</span> <span class="pre">(Silesian)'}</span></em><a class="headerlink" href="#searx.locales.ADDITIONAL_TRANSLATIONS" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Additional languages SearXNG has translations for but not supported by
|
||||
python-babel (see <a class="reference internal" href="#searx.locales.locales_initialize" title="searx.locales.locales_initialize"><code class="xref py py-obj docutils literal notranslate"><span class="pre">locales_initialize</span></code></a>).</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py data">
|
||||
<dt class="sig sig-object py" id="searx.locales.LOCALE_BEST_MATCH">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.locales.</span></span><span class="sig-name descname"><span class="pre">LOCALE_BEST_MATCH</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">{'dv':</span> <span class="pre">'si',</span> <span class="pre">'nl-BE':</span> <span class="pre">'nl',</span> <span class="pre">'oc':</span> <span class="pre">'fr-FR',</span> <span class="pre">'pap':</span> <span class="pre">'pt-BR',</span> <span class="pre">'szl':</span> <span class="pre">'pl',</span> <span class="pre">'zh-HK':</span> <span class="pre">'zh-Hant-TW'}</span></em><a class="headerlink" href="#searx.locales.LOCALE_BEST_MATCH" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Map a locale we do not have a translations for to a locale we have a
|
||||
translation for. By example: use Taiwan version of the translation for Hong
|
||||
Kong.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.locales.get_translations">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.locales.</span></span><span class="sig-name descname"><span class="pre">get_translations</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/locales.html#get_translations"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.locales.get_translations" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Monkey patch of <a class="reference external" href="https://python-babel.github.io/flask-babel/index.html#flask_babel.get_translations" title="(in Flask-Babel)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">flask_babel.get_translations</span></code></a></p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.locales.get_translation_locales">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.locales.</span></span><span class="sig-name descname"><span class="pre">get_translation_locales</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#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></span><a class="reference internal" href="../_modules/searx/locales.html#get_translation_locales"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.locales.get_translation_locales" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Returns the list of translation locales (<em>underscore</em>). The list is
|
||||
generated from the translation folders in <a class="extlink-origin reference external" href="https://github.com/searxng/searxng/blob/master/searx/translations">git://searx/translations</a></p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.locales.locales_initialize">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.locales.</span></span><span class="sig-name descname"><span class="pre">locales_initialize</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/locales.html#locales_initialize"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.locales.locales_initialize" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Initialize locales environment of the SearXNG session.</p>
|
||||
<ul class="simple">
|
||||
<li><p>monkey patch <a class="reference external" href="https://python-babel.github.io/flask-babel/index.html#flask_babel.get_translations" title="(in Flask-Babel)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">flask_babel.get_translations</span></code></a> by <a class="reference internal" href="#searx.locales.get_translations" title="searx.locales.get_translations"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_translations</span></code></a></p></li>
|
||||
<li><p>init global names <a class="reference internal" href="#searx.locales.LOCALE_NAMES" title="searx.locales.LOCALE_NAMES"><code class="xref py py-obj docutils literal notranslate"><span class="pre">LOCALE_NAMES</span></code></a>, <a class="reference internal" href="#searx.locales.RTL_LOCALES" title="searx.locales.RTL_LOCALES"><code class="xref py py-obj docutils literal notranslate"><span class="pre">RTL_LOCALES</span></code></a></p></li>
|
||||
</ul>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.locales.region_tag">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.locales.</span></span><span class="sig-name descname"><span class="pre">region_tag</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">locale</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://babel.readthedocs.io/en/latest/api/core.html#babel.core.Locale" title="(in Babel v2.2)"><span class="pre">Locale</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</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/locales.html#region_tag"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.locales.region_tag" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Returns SearXNG’s region tag from the locale (e.g. zh-TW , en-US).</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.locales.language_tag">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.locales.</span></span><span class="sig-name descname"><span class="pre">language_tag</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">locale</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://babel.readthedocs.io/en/latest/api/core.html#babel.core.Locale" title="(in Babel v2.2)"><span class="pre">Locale</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</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/locales.html#language_tag"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.locales.language_tag" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Returns SearXNG’s language tag from the locale and if exits, the tag
|
||||
includes the script name (e.g. en, zh_Hant).</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.locales.get_locale">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.locales.</span></span><span class="sig-name descname"><span class="pre">get_locale</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">locale_tag</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">→</span> <span class="sig-return-typehint"><a class="reference external" href="https://babel.readthedocs.io/en/latest/api/core.html#babel.core.Locale" title="(in Babel v2.2)"><span class="pre">Locale</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/locales.html#get_locale"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.locales.get_locale" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Returns a <code class="xref py py-obj docutils literal notranslate"><span class="pre">babel.Locale</span></code> object parsed from argument
|
||||
<code class="docutils literal notranslate"><span class="pre">locale_tag</span></code></p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.locales.get_official_locales">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.locales.</span></span><span class="sig-name descname"><span class="pre">get_official_locales</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">territory</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">languages</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">regional</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>, <em class="sig-param"><span class="n"><span class="pre">de_facto</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">True</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#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://babel.readthedocs.io/en/latest/api/core.html#babel.core.Locale" title="(in Babel v2.2)"><span class="pre">Locale</span></a><span class="p"><span class="pre">]</span></span></span></span><a class="reference internal" href="../_modules/searx/locales.html#get_official_locales"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.locales.get_official_locales" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Returns a list of <code class="xref py py-obj docutils literal notranslate"><span class="pre">babel.Locale</span></code> with languages from
|
||||
<a class="reference external" href="https://babel.readthedocs.io/en/latest/api/languages.html#babel.languages.get_official_languages" title="(in Babel v2.2)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">babel.languages.get_official_languages</span></code></a>.</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>territory</strong> – The territory (country or region) code.</p></li>
|
||||
<li><p><strong>languages</strong> – A list of language codes the languages from
|
||||
<a class="reference external" href="https://babel.readthedocs.io/en/latest/api/languages.html#babel.languages.get_official_languages" title="(in Babel v2.2)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">babel.languages.get_official_languages</span></code></a> should be in
|
||||
(intersection). If this argument is <code class="docutils literal notranslate"><span class="pre">None</span></code>, all official languages in
|
||||
this territory are used.</p></li>
|
||||
<li><p><strong>regional</strong> – If the regional flag is set, then languages which are
|
||||
regionally official are also returned.</p></li>
|
||||
<li><p><strong>de_facto</strong> – If the de_facto flag is set to <cite>False</cite>, then languages
|
||||
which are “de facto” official are not returned.</p></li>
|
||||
</ul>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.locales.get_engine_locale">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.locales.</span></span><span class="sig-name descname"><span class="pre">get_engine_locale</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">searxng_locale</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">engine_locales</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">default</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/locales.html#get_engine_locale"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.locales.get_engine_locale" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Return engine’s language (aka locale) string that best fits to argument
|
||||
<code class="docutils literal notranslate"><span class="pre">searxng_locale</span></code>.</p>
|
||||
<p>Argument <code class="docutils literal notranslate"><span class="pre">engine_locales</span></code> is a python dict that maps <em>SearXNG locales</em> to
|
||||
corresponding <em>engine locales</em>:</p>
|
||||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o"><</span><span class="n">engine</span><span class="o">></span><span class="p">:</span> <span class="p">{</span>
|
||||
<span class="c1"># SearXNG string : engine-string</span>
|
||||
<span class="s1">'ca-ES'</span> <span class="p">:</span> <span class="s1">'ca_ES'</span><span class="p">,</span>
|
||||
<span class="s1">'fr-BE'</span> <span class="p">:</span> <span class="s1">'fr_BE'</span><span class="p">,</span>
|
||||
<span class="s1">'fr-CA'</span> <span class="p">:</span> <span class="s1">'fr_CA'</span><span class="p">,</span>
|
||||
<span class="s1">'fr-CH'</span> <span class="p">:</span> <span class="s1">'fr_CH'</span><span class="p">,</span>
|
||||
<span class="s1">'fr'</span> <span class="p">:</span> <span class="s1">'fr_FR'</span><span class="p">,</span>
|
||||
<span class="o">...</span>
|
||||
<span class="s1">'pl-PL'</span> <span class="p">:</span> <span class="s1">'pl_PL'</span><span class="p">,</span>
|
||||
<span class="s1">'pt-PT'</span> <span class="p">:</span> <span class="s1">'pt_PT'</span>
|
||||
<span class="o">..</span>
|
||||
<span class="s1">'zh'</span> <span class="p">:</span> <span class="s1">'zh'</span>
|
||||
<span class="s1">'zh_Hans'</span> <span class="p">:</span> <span class="s1">'zh'</span>
|
||||
<span class="s1">'zh_Hant'</span> <span class="p">:</span> <span class="s1">'zh_TW'</span>
|
||||
<span class="p">}</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="admonition hint">
|
||||
<p class="admonition-title">Hint</p>
|
||||
<p>The <em>SearXNG locale</em> string has to be known by babel!</p>
|
||||
</div>
|
||||
<p>If there is no direct 1:1 mapping, this functions tries to narrow down
|
||||
engine’s language (locale). If no value can be determined by these
|
||||
approximation attempts the <code class="docutils literal notranslate"><span class="pre">default</span></code> value is returned.</p>
|
||||
<p>Assumptions:</p>
|
||||
<ol class="upperalpha simple">
|
||||
<li><p>When user select a language the results should be optimized according to
|
||||
the selected language.</p></li>
|
||||
<li><p>When user select a language and a territory the results should be
|
||||
optimized with first priority on territory and second on language.</p></li>
|
||||
</ol>
|
||||
<p>First approximation rule (<em>by territory</em>):</p>
|
||||
<blockquote>
|
||||
<div><p>When the user selects a locale with territory (and a language), the
|
||||
territory has priority over the language. If any of the official languages
|
||||
in the territory is supported by the engine (<code class="docutils literal notranslate"><span class="pre">engine_locales</span></code>) it will
|
||||
be used.</p>
|
||||
</div></blockquote>
|
||||
<p>Second approximation rule (<em>by language</em>):</p>
|
||||
<blockquote>
|
||||
<div><p>If “First approximation rule” brings no result or the user selects only a
|
||||
language without a territory. Check in which territories the language
|
||||
has an official status and if one of these territories is supported by the
|
||||
engine.</p>
|
||||
</div></blockquote>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.locales.match_locale">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.locales.</span></span><span class="sig-name descname"><span class="pre">match_locale</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">searxng_locale</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">locale_tag_list</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#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></em>, <em class="sig-param"><span class="n"><span class="pre">fallback</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">→</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/locales.html#match_locale"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.locales.match_locale" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Return tag from <code class="docutils literal notranslate"><span class="pre">locale_tag_list</span></code> that best fits to <code class="docutils literal notranslate"><span class="pre">searxng_locale</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>searxng_locale</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><em>str</em></a>) – SearXNG’s internal representation of locale (de,
|
||||
de-DE, fr-BE, zh, zh-CN, zh-TW ..).</p></li>
|
||||
<li><p><strong>locale_tag_list</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.13)"><em>list</em></a>) – The list of locale tags to select from</p></li>
|
||||
<li><p><strong>fallback</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><em>str</em></a>) – fallback locale tag (if unset –> <code class="docutils literal notranslate"><span class="pre">None</span></code>)</p></li>
|
||||
</ul>
|
||||
</dd>
|
||||
</dl>
|
||||
<p>The rules to find a match are implemented in <a class="reference internal" href="#searx.locales.get_engine_locale" title="searx.locales.get_engine_locale"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_engine_locale</span></code></a>,
|
||||
the <code class="docutils literal notranslate"><span class="pre">engine_locales</span></code> is build up by <a class="reference internal" href="#searx.locales.build_engine_locales" title="searx.locales.build_engine_locales"><code class="xref py py-obj docutils literal notranslate"><span class="pre">build_engine_locales</span></code></a>.</p>
|
||||
<div class="admonition hint">
|
||||
<p class="admonition-title">Hint</p>
|
||||
<p>The <em>SearXNG locale</em> string and the members of <code class="docutils literal notranslate"><span class="pre">locale_tag_list</span></code> has to
|
||||
be known by babel! The <a class="reference internal" href="#searx.locales.ADDITIONAL_TRANSLATIONS" title="searx.locales.ADDITIONAL_TRANSLATIONS"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ADDITIONAL_TRANSLATIONS</span></code></a> are used in the
|
||||
UI and are not known by babel –> will be ignored.</p>
|
||||
</div>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.locales.build_engine_locales">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.locales.</span></span><span class="sig-name descname"><span class="pre">build_engine_locales</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tag_list</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#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></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/locales.html#build_engine_locales"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.locales.build_engine_locales" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>From a list of locale tags a dictionary is build that can be passed by
|
||||
argument <code class="docutils literal notranslate"><span class="pre">engine_locales</span></code> to <a class="reference internal" href="#searx.locales.get_engine_locale" title="searx.locales.get_engine_locale"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_engine_locale</span></code></a>. This function
|
||||
is mainly used by <a class="reference internal" href="#searx.locales.match_locale" title="searx.locales.match_locale"><code class="xref py py-obj docutils literal notranslate"><span class="pre">match_locale</span></code></a> and is similar to what the
|
||||
<code class="docutils literal notranslate"><span class="pre">fetch_traits(..)</span></code> function of engines do.</p>
|
||||
<p>If there are territory codes in the <code class="docutils literal notranslate"><span class="pre">tag_list</span></code> that have a <em>script code</em>
|
||||
additional keys are added to the returned dictionary.</p>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">import</span><span class="w"> </span><span class="nn">locales</span>
|
||||
<span class="gp">>>> </span><span class="n">engine_locales</span> <span class="o">=</span> <span class="n">locales</span><span class="o">.</span><span class="n">build_engine_locales</span><span class="p">([</span><span class="s1">'en'</span><span class="p">,</span> <span class="s1">'en-US'</span><span class="p">,</span> <span class="s1">'zh'</span><span class="p">,</span> <span class="s1">'zh-CN'</span><span class="p">,</span> <span class="s1">'zh-TW'</span><span class="p">])</span>
|
||||
<span class="gp">>>> </span><span class="n">engine_locales</span>
|
||||
<span class="go">{</span>
|
||||
<span class="go"> 'en': 'en', 'en-US': 'en-US',</span>
|
||||
<span class="go"> 'zh': 'zh', 'zh-CN': 'zh-CN', 'zh_Hans': 'zh-CN',</span>
|
||||
<span class="go"> 'zh-TW': 'zh-TW', 'zh_Hant': 'zh-TW'</span>
|
||||
<span class="go">}</span>
|
||||
<span class="gp">>>> </span><span class="n">get_engine_locale</span><span class="p">(</span><span class="s1">'zh-Hans'</span><span class="p">,</span> <span class="n">engine_locales</span><span class="p">)</span>
|
||||
<span class="go">'zh-CN'</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>This function is a good example to understand the language/region model
|
||||
of SearXNG:</p>
|
||||
<blockquote>
|
||||
<div><p>SearXNG only distinguishes between <strong>search languages</strong> and <strong>search
|
||||
regions</strong>, by adding the <em>script-tags</em>, languages with <em>script-tags</em> can
|
||||
be assigned to the <strong>regions</strong> that SearXNG supports.</p>
|
||||
</div></blockquote>
|
||||
</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 current"><a class="current reference internal" href="#">Locales</a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searxngs-locale-data">SearXNG’s locale data</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#module-searx.sxng_locales">SearXNG’s locale codes</a><ul>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.sxng_locales.sxng_locales"><code class="docutils literal notranslate"><span class="pre">sxng_locales</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searxngs-locale-implementations">SearXNG’s locale implementations</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.locales.LOCALE_NAMES"><code class="docutils literal notranslate"><span class="pre">LOCALE_NAMES</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.locales.RTL_LOCALES"><code class="docutils literal notranslate"><span class="pre">RTL_LOCALES</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.locales.ADDITIONAL_TRANSLATIONS"><code class="docutils literal notranslate"><span class="pre">ADDITIONAL_TRANSLATIONS</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.locales.LOCALE_BEST_MATCH"><code class="docutils literal notranslate"><span class="pre">LOCALE_BEST_MATCH</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.locales.get_translations"><code class="docutils literal notranslate"><span class="pre">get_translations()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.locales.get_translation_locales"><code class="docutils literal notranslate"><span class="pre">get_translation_locales()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.locales.locales_initialize"><code class="docutils literal notranslate"><span class="pre">locales_initialize()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.locales.region_tag"><code class="docutils literal notranslate"><span class="pre">region_tag()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.locales.language_tag"><code class="docutils literal notranslate"><span class="pre">language_tag()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.locales.get_locale"><code class="docutils literal notranslate"><span class="pre">get_locale()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.locales.get_official_locales"><code class="docutils literal notranslate"><span class="pre">get_official_locales()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.locales.get_engine_locale"><code class="docutils literal notranslate"><span class="pre">get_engine_locale()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.locales.match_locale"><code class="docutils literal notranslate"><span class="pre">match_locale()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.locales.build_engine_locales"><code class="docutils literal notranslate"><span class="pre">build_engine_locales()</span></code></a></li>
|
||||
</ul>
|
||||
</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"><a class="reference internal" href="searx.utils.html">Utility functions for the engines</a></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.infopage.html" title="previous chapter">Online <code class="docutils literal notranslate"><span class="pre">/info</span></code></a>
|
||||
<li>Next: <a href="searx.redisdb.html" title="next chapter">Redis 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.locales.rst.txt"
|
||||
rel="nofollow">Show Source</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright SearXNG team.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
159
src/searx.redisdb.html
Normal file
159
src/searx.redisdb.html
Normal file
@@ -0,0 +1,159 @@
|
||||
<!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>Redis DB — SearXNG Documentation (2025.4.11+2287a6826)</title>
|
||||
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=6625fa76" />
|
||||
<link rel="stylesheet" type="text/css" href="../_static/searxng.css?v=52e4ff28" />
|
||||
<script src="../_static/documentation_options.js?v=725693a2"></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.4.11+2287a6826" 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="next" title="Redis Library" href="searx.redislib.html" />
|
||||
<link rel="prev" title="Locales" href="searx.locales.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.redislib.html" title="Redis Library"
|
||||
accesskey="N">next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="searx.locales.html" title="Locales"
|
||||
accesskey="P">previous</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../index.html">SearXNG Documentation (2025.4.11+2287a6826)</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Source-Code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">Redis DB</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<section id="redis-db">
|
||||
<span id="id1"></span><h1>Redis DB<a class="headerlink" href="#redis-db" title="Link to this heading">¶</a></h1>
|
||||
<p id="module-searx.redisdb">Implementation of the redis client (<a class="reference external" href="https://github.com/redis/redis-py">redis-py</a>).</p>
|
||||
<p>This implementation uses the <a class="reference internal" href="../admin/settings/settings_redis.html#settings-redis"><span class="std std-ref">redis:</span></a> setup from <code class="docutils literal notranslate"><span class="pre">settings.yml</span></code>.
|
||||
A redis DB connect can be tested by:</p>
|
||||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span><span class="w"> </span><span class="nn">searx</span><span class="w"> </span><span class="kn">import</span> <span class="n">redisdb</span>
|
||||
<span class="gp">>>> </span><span class="n">redisdb</span><span class="o">.</span><span class="n">initialize</span><span class="p">()</span>
|
||||
<span class="go">True</span>
|
||||
<span class="gp">>>> </span><span class="n">db</span> <span class="o">=</span> <span class="n">redisdb</span><span class="o">.</span><span class="n">client</span><span class="p">()</span>
|
||||
<span class="gp">>>> </span><span class="n">db</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"foo"</span><span class="p">,</span> <span class="s2">"bar"</span><span class="p">)</span>
|
||||
<span class="go">True</span>
|
||||
<span class="gp">>>> </span><span class="n">db</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"foo"</span><span class="p">)</span>
|
||||
<span class="go">b'bar'</span>
|
||||
<span class="gp">>>></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<dl class="py data">
|
||||
<dt class="sig sig-object py" id="searx.redisdb.OLD_REDIS_URL_DEFAULT_URL">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.redisdb.</span></span><span class="sig-name descname"><span class="pre">OLD_REDIS_URL_DEFAULT_URL</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">'unix:///usr/local/searxng-redis/run/redis.sock?db=0'</span></em><a class="headerlink" href="#searx.redisdb.OLD_REDIS_URL_DEFAULT_URL" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>This was the default Redis URL in settings.yml.</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 current"><a class="current reference internal" href="#">Redis DB</a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.redisdb.OLD_REDIS_URL_DEFAULT_URL"><code class="docutils literal notranslate"><span class="pre">OLD_REDIS_URL_DEFAULT_URL</span></code></a></li>
|
||||
</ul>
|
||||
</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"><a class="reference internal" href="searx.utils.html">Utility functions for the engines</a></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.locales.html" title="previous chapter">Locales</a>
|
||||
<li>Next: <a href="searx.redislib.html" title="next chapter">Redis Library</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.redisdb.rst.txt"
|
||||
rel="nofollow">Show Source</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright SearXNG team.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
291
src/searx.redislib.html
Normal file
291
src/searx.redislib.html
Normal file
@@ -0,0 +1,291 @@
|
||||
<!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>Redis Library — SearXNG Documentation (2025.4.11+2287a6826)</title>
|
||||
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=6625fa76" />
|
||||
<link rel="stylesheet" type="text/css" href="../_static/searxng.css?v=52e4ff28" />
|
||||
<script src="../_static/documentation_options.js?v=725693a2"></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.4.11+2287a6826" 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="next" title="Search" href="searx.search.html" />
|
||||
<link rel="prev" title="Redis DB" href="searx.redisdb.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.search.html" title="Search"
|
||||
accesskey="N">next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="searx.redisdb.html" title="Redis DB"
|
||||
accesskey="P">previous</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../index.html">SearXNG Documentation (2025.4.11+2287a6826)</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Source-Code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">Redis Library</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<section id="module-searx.redislib">
|
||||
<span id="redis-library"></span><span id="searx-redis"></span><h1>Redis Library<a class="headerlink" href="#module-searx.redislib" title="Link to this heading">¶</a></h1>
|
||||
<p>A collection of convenient functions and redis/lua scripts.</p>
|
||||
<p>This code was partial inspired by the <a class="reference external" href="https://redis.com/blog/bullet-proofing-lua-scripts-in-redispy/">Bullet-Proofing Lua Scripts in RedisPy</a>
|
||||
article.</p>
|
||||
<dl class="py data">
|
||||
<dt class="sig sig-object py" id="searx.redislib.LUA_SCRIPT_STORAGE">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.redislib.</span></span><span class="sig-name descname"><span class="pre">LUA_SCRIPT_STORAGE</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">{}</span></em><a class="headerlink" href="#searx.redislib.LUA_SCRIPT_STORAGE" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>A global dictionary to cache client’s <code class="docutils literal notranslate"><span class="pre">Script</span></code> objects, used by
|
||||
<a class="reference internal" href="#searx.redislib.lua_script_storage" title="searx.redislib.lua_script_storage"><code class="xref py py-obj docutils literal notranslate"><span class="pre">lua_script_storage</span></code></a></p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.redislib.lua_script_storage">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.redislib.</span></span><span class="sig-name descname"><span class="pre">lua_script_storage</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">client</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">script</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/redislib.html#lua_script_storage"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.redislib.lua_script_storage" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Returns a redis <a class="reference external" href="https://redis.readthedocs.io/en/stable/commands.html#redis.commands.core.CoreCommands.register_script" title="(in redis-py v99.99.99)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Script</span></code></a> instance.</p>
|
||||
<p>Due to performance reason the <code class="docutils literal notranslate"><span class="pre">Script</span></code> object is instantiated only once
|
||||
for a client (<code class="docutils literal notranslate"><span class="pre">client.register_script(..)</span></code>) and is cached in
|
||||
<a class="reference internal" href="#searx.redislib.LUA_SCRIPT_STORAGE" title="searx.redislib.LUA_SCRIPT_STORAGE"><code class="xref py py-obj docutils literal notranslate"><span class="pre">LUA_SCRIPT_STORAGE</span></code></a>.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.redislib.purge_by_prefix">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.redislib.</span></span><span class="sig-name descname"><span class="pre">purge_by_prefix</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">client</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">prefix</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">'SearXNG_'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/redislib.html#purge_by_prefix"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.redislib.purge_by_prefix" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Purge all keys with <code class="docutils literal notranslate"><span class="pre">prefix</span></code> from database.</p>
|
||||
<p>Queries all keys in the database by the given prefix and set expire time to
|
||||
zero. The default prefix will drop all keys which has been set by SearXNG
|
||||
(drops SearXNG schema entirely from database).</p>
|
||||
<p>The implementation is the lua script from string <code class="xref py py-obj docutils literal notranslate"><span class="pre">PURGE_BY_PREFIX</span></code>.
|
||||
The lua script uses <a class="reference external" href="https://redis.io/commands/expire/">EXPIRE</a> instead of <a class="reference external" href="https://redis.io/commands/del/">DEL</a>: if there are a lot keys to
|
||||
delete and/or their values are big, <cite>DEL</cite> could take more time and blocks
|
||||
the command loop while <cite>EXPIRE</cite> turns back immediate.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||||
<dd class="field-odd"><p><strong>prefix</strong> – prefix of the key to delete (default: <code class="docutils literal notranslate"><span class="pre">SearXNG_</span></code>)</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.redislib.secret_hash">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.redislib.</span></span><span class="sig-name descname"><span class="pre">secret_hash</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><a class="reference internal" href="../_modules/searx/redislib.html#secret_hash"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.redislib.secret_hash" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Creates a hash of the <code class="docutils literal notranslate"><span class="pre">name</span></code>.</p>
|
||||
<p>Combines argument <code class="docutils literal notranslate"><span class="pre">name</span></code> with the <code class="docutils literal notranslate"><span class="pre">secret_key</span></code> from <a class="reference internal" href="../admin/settings/settings_server.html#settings-server"><span class="std std-ref">server:</span></a>. This function can be used to get a more anonymized name of a Redis
|
||||
KEY.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||||
<dd class="field-odd"><p><strong>name</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 name to create a secret hash for</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.redislib.incr_counter">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.redislib.</span></span><span class="sig-name descname"><span class="pre">incr_counter</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">client</span></span></em>, <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>, <em class="sig-param"><span class="n"><span class="pre">limit</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><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expire</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><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/redislib.html#incr_counter"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.redislib.incr_counter" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Increment a counter and return the new value.</p>
|
||||
<p>If counter with redis key <code class="docutils literal notranslate"><span class="pre">SearXNG_counter_<name></span></code> does not exists it is
|
||||
created with initial value 1 returned. The replacement <code class="docutils literal notranslate"><span class="pre"><name></span></code> is a
|
||||
<em>secret hash</em> of the value from argument <code class="docutils literal notranslate"><span class="pre">name</span></code> (see
|
||||
<a class="reference internal" href="#searx.redislib.secret_hash" title="searx.redislib.secret_hash"><code class="xref py py-func docutils literal notranslate"><span class="pre">secret_hash()</span></code></a>).</p>
|
||||
<p>The implementation of the redis counter is the lua script from string
|
||||
<code class="xref py py-obj docutils literal notranslate"><span class="pre">INCR_COUNTER</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>name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><em>str</em></a>) – name of the counter</p></li>
|
||||
<li><p><strong>expire</strong> (int / see <a class="reference external" href="https://redis.io/commands/expire/">EXPIRE</a>) – live-time of the counter in seconds (default <code class="docutils literal notranslate"><span class="pre">None</span></code> means
|
||||
infinite).</p></li>
|
||||
<li><p><strong>limit</strong> (int / limit is 2^64 see <a class="reference external" href="https://redis.io/commands/incr/">INCR</a>) – limit where the counter stops to increment (default <code class="docutils literal notranslate"><span class="pre">None</span></code>)</p></li>
|
||||
</ul>
|
||||
</dd>
|
||||
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
||||
<dd class="field-even"><p>value of the incremented counter</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<p>A simple demo of a counter with expire time and limit:</p>
|
||||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">6</span><span class="p">):</span>
|
||||
<span class="gp">... </span> <span class="n">i</span><span class="p">,</span> <span class="n">incr_counter</span><span class="p">(</span><span class="n">client</span><span class="p">,</span> <span class="s2">"foo"</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">5</span><span class="p">)</span> <span class="c1"># max 3, duration 5 sec</span>
|
||||
<span class="gp">... </span> <span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="c1"># from the third call on max has been reached</span>
|
||||
<span class="gp">...</span>
|
||||
<span class="go">(0, 1)</span>
|
||||
<span class="go">(1, 2)</span>
|
||||
<span class="go">(2, 3)</span>
|
||||
<span class="go">(3, 3)</span>
|
||||
<span class="go">(4, 3)</span>
|
||||
<span class="go">(5, 1)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.redislib.drop_counter">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.redislib.</span></span><span class="sig-name descname"><span class="pre">drop_counter</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">client</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/redislib.html#drop_counter"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.redislib.drop_counter" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Drop counter with redis key <code class="docutils literal notranslate"><span class="pre">SearXNG_counter_<name></span></code></p>
|
||||
<p>The replacement <code class="docutils literal notranslate"><span class="pre"><name></span></code> is a <em>secret hash</em> of the value from argument
|
||||
<code class="docutils literal notranslate"><span class="pre">name</span></code> (see <a class="reference internal" href="#searx.redislib.incr_counter" title="searx.redislib.incr_counter"><code class="xref py py-func docutils literal notranslate"><span class="pre">incr_counter()</span></code></a> and <a class="reference internal" href="#searx.redislib.incr_sliding_window" title="searx.redislib.incr_sliding_window"><code class="xref py py-func docutils literal notranslate"><span class="pre">incr_sliding_window()</span></code></a>).</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.redislib.incr_sliding_window">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.redislib.</span></span><span class="sig-name descname"><span class="pre">incr_sliding_window</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">client</span></span></em>, <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>, <em class="sig-param"><span class="n"><span class="pre">duration</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></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/redislib.html#incr_sliding_window"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.redislib.incr_sliding_window" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Increment a sliding-window counter and return the new value.</p>
|
||||
<p>If counter with redis key <code class="docutils literal notranslate"><span class="pre">SearXNG_counter_<name></span></code> does not exists it is
|
||||
created with initial value 1 returned. The replacement <code class="docutils literal notranslate"><span class="pre"><name></span></code> is a
|
||||
<em>secret hash</em> of the value from argument <code class="docutils literal notranslate"><span class="pre">name</span></code> (see
|
||||
<a class="reference internal" href="#searx.redislib.secret_hash" title="searx.redislib.secret_hash"><code class="xref py py-func docutils literal notranslate"><span class="pre">secret_hash()</span></code></a>).</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>name</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><em>str</em></a>) – name of the counter</p></li>
|
||||
<li><p><strong>duration</strong> – live-time of the sliding window in seconds</p></li>
|
||||
</ul>
|
||||
</dd>
|
||||
<dt class="field-even">Typeduration<span class="colon">:</span></dt>
|
||||
<dd class="field-even"><p>int</p>
|
||||
</dd>
|
||||
<dt class="field-odd">Returns<span class="colon">:</span></dt>
|
||||
<dd class="field-odd"><p>value of the incremented counter</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<p>The implementation of the redis counter is the lua script from string
|
||||
<code class="xref py py-obj docutils literal notranslate"><span class="pre">INCR_SLIDING_WINDOW</span></code>. The lua script uses <a class="reference external" href="https://redis.com/ebook/part-1-getting-started/chapter-1-getting-to-know-redis/1-2-what-redis-data-structures-look-like/1-2-5-sorted-sets-in-redis/">sorted sets in Redis</a>
|
||||
to implement a sliding window for the redis key <code class="docutils literal notranslate"><span class="pre">SearXNG_counter_<name></span></code>
|
||||
(<a class="reference external" href="https://redis.io/commands/zadd/">ZADD</a>). The current <a class="reference external" href="https://redis.io/commands/time/">TIME</a> is used to score the items in the sorted set and
|
||||
the time window is moved by removing items with a score lower current time
|
||||
minus <em>duration</em> time (<a class="reference external" href="https://redis.io/commands/zremrangebyscore/">ZREMRANGEBYSCORE</a>).</p>
|
||||
<p>The <a class="reference external" href="https://redis.io/commands/expire/">EXPIRE</a> time (the duration of the sliding window) is refreshed on each
|
||||
call (increment) and if there is no call in this duration, the sorted
|
||||
set expires from the redis DB.</p>
|
||||
<p>The return value is the amount of items in the sorted set (<a class="reference external" href="https://redis.io/commands/zcount/">ZCOUNT</a>), what
|
||||
means the number of calls in the sliding window.</p>
|
||||
<p>A simple demo of the sliding window:</p>
|
||||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">5</span><span class="p">):</span>
|
||||
<span class="gp">... </span> <span class="n">incr_sliding_window</span><span class="p">(</span><span class="n">client</span><span class="p">,</span> <span class="s2">"foo"</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span> <span class="c1"># duration 3 sec</span>
|
||||
<span class="gp">... </span> <span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="c1"># from the third call (second) on the window is moved</span>
|
||||
<span class="gp">...</span>
|
||||
<span class="go">1</span>
|
||||
<span class="go">2</span>
|
||||
<span class="go">3</span>
|
||||
<span class="go">3</span>
|
||||
<span class="go">3</span>
|
||||
<span class="gp">>>> </span><span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span> <span class="c1"># wait until expire</span>
|
||||
<span class="gp">>>> </span><span class="n">incr_sliding_window</span><span class="p">(</span><span class="n">client</span><span class="p">,</span> <span class="s2">"foo"</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
|
||||
<span class="go">1</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</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.redisdb.html">Redis DB</a></li>
|
||||
<li class="toctree-l2 current"><a class="current reference internal" href="#">Redis Library</a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.redislib.LUA_SCRIPT_STORAGE"><code class="docutils literal notranslate"><span class="pre">LUA_SCRIPT_STORAGE</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.redislib.lua_script_storage"><code class="docutils literal notranslate"><span class="pre">lua_script_storage()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.redislib.purge_by_prefix"><code class="docutils literal notranslate"><span class="pre">purge_by_prefix()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.redislib.secret_hash"><code class="docutils literal notranslate"><span class="pre">secret_hash()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.redislib.incr_counter"><code class="docutils literal notranslate"><span class="pre">incr_counter()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.redislib.drop_counter"><code class="docutils literal notranslate"><span class="pre">drop_counter()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.redislib.incr_sliding_window"><code class="docutils literal notranslate"><span class="pre">incr_sliding_window()</span></code></a></li>
|
||||
</ul>
|
||||
</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"><a class="reference internal" href="searx.utils.html">Utility functions for the engines</a></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.redisdb.html" title="previous chapter">Redis DB</a>
|
||||
<li>Next: <a href="searx.search.html" title="next chapter">Search</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.redislib.rst.txt"
|
||||
rel="nofollow">Show Source</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright SearXNG team.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
218
src/searx.search.html
Normal file
218
src/searx.search.html
Normal file
File diff suppressed because one or more lines are too long
301
src/searx.search.processors.html
Normal file
301
src/searx.search.processors.html
Normal file
@@ -0,0 +1,301 @@
|
||||
<!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>Search processors — SearXNG Documentation (2025.4.11+2287a6826)</title>
|
||||
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=6625fa76" />
|
||||
<link rel="stylesheet" type="text/css" href="../_static/searxng.css?v=52e4ff28" />
|
||||
<script src="../_static/documentation_options.js?v=725693a2"></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.4.11+2287a6826" 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="next" title="Settings Loader" href="searx.settings.html" />
|
||||
<link rel="prev" title="Search" href="searx.search.html" />
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="Related">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="searx.settings.html" title="Settings Loader"
|
||||
accesskey="N">next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="searx.search.html" title="Search"
|
||||
accesskey="P">previous</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../index.html">SearXNG Documentation (2025.4.11+2287a6826)</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Source-Code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">Search processors</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<section id="search-processors">
|
||||
<span id="searx-search-processors"></span><h1>Search processors<a class="headerlink" href="#search-processors" title="Link to this heading">¶</a></h1>
|
||||
<nav class="contents local" id="contents">
|
||||
<ul class="simple">
|
||||
<li><p><a class="reference internal" href="#module-searx.search.processors.abstract" id="id1">Abstract processor class</a></p></li>
|
||||
<li><p><a class="reference internal" href="#module-searx.search.processors.offline" id="id2">Offline processor</a></p></li>
|
||||
<li><p><a class="reference internal" href="#module-searx.search.processors.online" id="id3">Online processor</a></p></li>
|
||||
<li><p><a class="reference internal" href="#module-searx.search.processors.online_currency" id="id4">Online currency processor</a></p></li>
|
||||
<li><p><a class="reference internal" href="#module-searx.search.processors.online_dictionary" id="id5">Online dictionary processor</a></p></li>
|
||||
<li><p><a class="reference internal" href="#module-searx.search.processors.online_url_search" id="id6">Online URL search processor</a></p></li>
|
||||
</ul>
|
||||
</nav>
|
||||
<section id="module-searx.search.processors.abstract">
|
||||
<span id="abstract-processor-class"></span><h2><a class="toc-backref" href="#id1" role="doc-backlink">Abstract processor class</a><a class="headerlink" href="#module-searx.search.processors.abstract" title="Link to this heading">¶</a></h2>
|
||||
<p>Abstract base classes for engine request processors.</p>
|
||||
<dl class="py class">
|
||||
<dt class="sig sig-object py" id="searx.search.processors.abstract.SuspendedStatus">
|
||||
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">searx.search.processors.abstract.</span></span><span class="sig-name descname"><span class="pre">SuspendedStatus</span></span><a class="reference internal" href="../_modules/searx/search/processors/abstract.html#SuspendedStatus"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.search.processors.abstract.SuspendedStatus" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Class to handle suspend state.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py class">
|
||||
<dt class="sig sig-object py" id="searx.search.processors.abstract.EngineProcessor">
|
||||
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">searx.search.processors.abstract.</span></span><span class="sig-name descname"><span class="pre">EngineProcessor</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">engine</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">engine_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><a class="reference internal" href="../_modules/searx/search/processors/abstract.html#EngineProcessor"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.search.processors.abstract.EngineProcessor" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Base classes used for all types of request processors.</p>
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.search.processors.abstract.EngineProcessor.get_params">
|
||||
<span class="sig-name descname"><span class="pre">get_params</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">search_query</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">engine_category</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/search/processors/abstract.html#EngineProcessor.get_params"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.search.processors.abstract.EngineProcessor.get_params" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Returns a set of (see <a class="reference internal" href="../dev/engines/engine_overview.html#engine-request-arguments"><span class="std std-ref">request params</span></a>) or
|
||||
<code class="docutils literal notranslate"><span class="pre">None</span></code> if request is not supported.</p>
|
||||
<p>Not supported conditions (<code class="docutils literal notranslate"><span class="pre">None</span></code> is returned):</p>
|
||||
<ul class="simple">
|
||||
<li><p>A page-number > 1 when engine does not support paging.</p></li>
|
||||
<li><p>A time range when the engine does not support time range.</p></li>
|
||||
</ul>
|
||||
</dd></dl>
|
||||
|
||||
</dd></dl>
|
||||
|
||||
</section>
|
||||
<section id="module-searx.search.processors.offline">
|
||||
<span id="offline-processor"></span><h2><a class="toc-backref" href="#id2" role="doc-backlink">Offline processor</a><a class="headerlink" href="#module-searx.search.processors.offline" title="Link to this heading">¶</a></h2>
|
||||
<p>Processors for engine-type: <code class="docutils literal notranslate"><span class="pre">offline</span></code></p>
|
||||
<dl class="py class">
|
||||
<dt class="sig sig-object py" id="searx.search.processors.offline.OfflineProcessor">
|
||||
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">searx.search.processors.offline.</span></span><span class="sig-name descname"><span class="pre">OfflineProcessor</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">engine</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">engine_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><a class="reference internal" href="../_modules/searx/search/processors/offline.html#OfflineProcessor"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.search.processors.offline.OfflineProcessor" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Processor class used by <code class="docutils literal notranslate"><span class="pre">offline</span></code> engines</p>
|
||||
</dd></dl>
|
||||
|
||||
</section>
|
||||
<section id="module-searx.search.processors.online">
|
||||
<span id="online-processor"></span><h2><a class="toc-backref" href="#id3" role="doc-backlink">Online processor</a><a class="headerlink" href="#module-searx.search.processors.online" title="Link to this heading">¶</a></h2>
|
||||
<p>Processors for engine-type: <code class="docutils literal notranslate"><span class="pre">online</span></code></p>
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.search.processors.online.default_request_params">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.search.processors.online.</span></span><span class="sig-name descname"><span class="pre">default_request_params</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/search/processors/online.html#default_request_params"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.search.processors.online.default_request_params" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Default request parameters for <code class="docutils literal notranslate"><span class="pre">online</span></code> engines.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py class">
|
||||
<dt class="sig sig-object py" id="searx.search.processors.online.OnlineProcessor">
|
||||
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">searx.search.processors.online.</span></span><span class="sig-name descname"><span class="pre">OnlineProcessor</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">engine</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">engine_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><a class="reference internal" href="../_modules/searx/search/processors/online.html#OnlineProcessor"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.search.processors.online.OnlineProcessor" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Processor class for <code class="docutils literal notranslate"><span class="pre">online</span></code> engines.</p>
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.search.processors.online.OnlineProcessor.get_params">
|
||||
<span class="sig-name descname"><span class="pre">get_params</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">search_query</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">engine_category</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/search/processors/online.html#OnlineProcessor.get_params"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.search.processors.online.OnlineProcessor.get_params" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Returns a set of <a class="reference internal" href="../dev/engines/engine_overview.html#engine-request-online"><span class="std std-ref">request params</span></a> or <code class="docutils literal notranslate"><span class="pre">None</span></code>
|
||||
if request is not supported.</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd></dl>
|
||||
|
||||
</section>
|
||||
<section id="module-searx.search.processors.online_currency">
|
||||
<span id="online-currency-processor"></span><h2><a class="toc-backref" href="#id4" role="doc-backlink">Online currency processor</a><a class="headerlink" href="#module-searx.search.processors.online_currency" title="Link to this heading">¶</a></h2>
|
||||
<p>Processors for engine-type: <code class="docutils literal notranslate"><span class="pre">online_currency</span></code></p>
|
||||
<dl class="py class">
|
||||
<dt class="sig sig-object py" id="searx.search.processors.online_currency.OnlineCurrencyProcessor">
|
||||
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">searx.search.processors.online_currency.</span></span><span class="sig-name descname"><span class="pre">OnlineCurrencyProcessor</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">engine</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">engine_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><a class="reference internal" href="../_modules/searx/search/processors/online_currency.html#OnlineCurrencyProcessor"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.search.processors.online_currency.OnlineCurrencyProcessor" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Processor class used by <code class="docutils literal notranslate"><span class="pre">online_currency</span></code> engines.</p>
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.search.processors.online_currency.OnlineCurrencyProcessor.get_params">
|
||||
<span class="sig-name descname"><span class="pre">get_params</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">search_query</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">engine_category</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/search/processors/online_currency.html#OnlineCurrencyProcessor.get_params"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.search.processors.online_currency.OnlineCurrencyProcessor.get_params" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Returns a set of <a class="reference internal" href="../dev/engines/engine_overview.html#engine-request-online-currency"><span class="std std-ref">request params</span></a>
|
||||
or <code class="docutils literal notranslate"><span class="pre">None</span></code> if search query does not match to <code class="xref py py-obj docutils literal notranslate"><span class="pre">parser_re</span></code>.</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd></dl>
|
||||
|
||||
</section>
|
||||
<section id="module-searx.search.processors.online_dictionary">
|
||||
<span id="online-dictionary-processor"></span><h2><a class="toc-backref" href="#id5" role="doc-backlink">Online dictionary processor</a><a class="headerlink" href="#module-searx.search.processors.online_dictionary" title="Link to this heading">¶</a></h2>
|
||||
<p>Processors for engine-type: <code class="docutils literal notranslate"><span class="pre">online_dictionary</span></code></p>
|
||||
<dl class="py class">
|
||||
<dt class="sig sig-object py" id="searx.search.processors.online_dictionary.OnlineDictionaryProcessor">
|
||||
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">searx.search.processors.online_dictionary.</span></span><span class="sig-name descname"><span class="pre">OnlineDictionaryProcessor</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">engine</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">engine_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><a class="reference internal" href="../_modules/searx/search/processors/online_dictionary.html#OnlineDictionaryProcessor"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.search.processors.online_dictionary.OnlineDictionaryProcessor" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Processor class used by <code class="docutils literal notranslate"><span class="pre">online_dictionary</span></code> engines.</p>
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.search.processors.online_dictionary.OnlineDictionaryProcessor.get_params">
|
||||
<span class="sig-name descname"><span class="pre">get_params</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">search_query</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">engine_category</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/search/processors/online_dictionary.html#OnlineDictionaryProcessor.get_params"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.search.processors.online_dictionary.OnlineDictionaryProcessor.get_params" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Returns a set of <a class="reference internal" href="../dev/engines/engine_overview.html#engine-request-online-dictionary"><span class="std std-ref">request params</span></a> or
|
||||
<code class="docutils literal notranslate"><span class="pre">None</span></code> if search query does not match to <code class="xref py py-obj docutils literal notranslate"><span class="pre">parser_re</span></code>.</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd></dl>
|
||||
|
||||
</section>
|
||||
<section id="module-searx.search.processors.online_url_search">
|
||||
<span id="online-url-search-processor"></span><h2><a class="toc-backref" href="#id6" role="doc-backlink">Online URL search processor</a><a class="headerlink" href="#module-searx.search.processors.online_url_search" title="Link to this heading">¶</a></h2>
|
||||
<p>Processors for engine-type: <code class="docutils literal notranslate"><span class="pre">online_url_search</span></code></p>
|
||||
<dl class="py class">
|
||||
<dt class="sig sig-object py" id="searx.search.processors.online_url_search.OnlineUrlSearchProcessor">
|
||||
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">searx.search.processors.online_url_search.</span></span><span class="sig-name descname"><span class="pre">OnlineUrlSearchProcessor</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">engine</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">engine_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><a class="reference internal" href="../_modules/searx/search/processors/online_url_search.html#OnlineUrlSearchProcessor"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.search.processors.online_url_search.OnlineUrlSearchProcessor" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Processor class used by <code class="docutils literal notranslate"><span class="pre">online_url_search</span></code> engines.</p>
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.search.processors.online_url_search.OnlineUrlSearchProcessor.get_params">
|
||||
<span class="sig-name descname"><span class="pre">get_params</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">search_query</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">engine_category</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/search/processors/online_url_search.html#OnlineUrlSearchProcessor.get_params"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.search.processors.online_url_search.OnlineUrlSearchProcessor.get_params" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Returns a set of <a class="reference internal" href="../dev/engines/engine_overview.html#engine-request-online"><span class="std std-ref">request params</span></a> or <code class="docutils literal notranslate"><span class="pre">None</span></code> if
|
||||
search query does not match to <code class="xref py py-obj docutils literal notranslate"><span class="pre">re_search_urls</span></code>.</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd></dl>
|
||||
|
||||
</section>
|
||||
</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.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 current"><a class="current reference internal" href="#">Search processors</a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#module-searx.search.processors.abstract">Abstract processor class</a><ul>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.search.processors.abstract.SuspendedStatus"><code class="docutils literal notranslate"><span class="pre">SuspendedStatus</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.search.processors.abstract.EngineProcessor"><code class="docutils literal notranslate"><span class="pre">EngineProcessor</span></code></a><ul>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.search.processors.abstract.EngineProcessor.get_params"><code class="docutils literal notranslate"><span class="pre">EngineProcessor.get_params()</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#module-searx.search.processors.offline">Offline processor</a><ul>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.search.processors.offline.OfflineProcessor"><code class="docutils literal notranslate"><span class="pre">OfflineProcessor</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#module-searx.search.processors.online">Online processor</a><ul>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.search.processors.online.default_request_params"><code class="docutils literal notranslate"><span class="pre">default_request_params()</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.search.processors.online.OnlineProcessor"><code class="docutils literal notranslate"><span class="pre">OnlineProcessor</span></code></a><ul>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.search.processors.online.OnlineProcessor.get_params"><code class="docutils literal notranslate"><span class="pre">OnlineProcessor.get_params()</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#module-searx.search.processors.online_currency">Online currency processor</a><ul>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.search.processors.online_currency.OnlineCurrencyProcessor"><code class="docutils literal notranslate"><span class="pre">OnlineCurrencyProcessor</span></code></a><ul>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.search.processors.online_currency.OnlineCurrencyProcessor.get_params"><code class="docutils literal notranslate"><span class="pre">OnlineCurrencyProcessor.get_params()</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#module-searx.search.processors.online_dictionary">Online dictionary processor</a><ul>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.search.processors.online_dictionary.OnlineDictionaryProcessor"><code class="docutils literal notranslate"><span class="pre">OnlineDictionaryProcessor</span></code></a><ul>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.search.processors.online_dictionary.OnlineDictionaryProcessor.get_params"><code class="docutils literal notranslate"><span class="pre">OnlineDictionaryProcessor.get_params()</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#module-searx.search.processors.online_url_search">Online URL search processor</a><ul>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.search.processors.online_url_search.OnlineUrlSearchProcessor"><code class="docutils literal notranslate"><span class="pre">OnlineUrlSearchProcessor</span></code></a><ul>
|
||||
<li class="toctree-l5"><a class="reference internal" href="#searx.search.processors.online_url_search.OnlineUrlSearchProcessor.get_params"><code class="docutils literal notranslate"><span class="pre">OnlineUrlSearchProcessor.get_params()</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</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"><a class="reference internal" href="searx.utils.html">Utility functions for the engines</a></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.search.html" title="previous chapter">Search</a>
|
||||
<li>Next: <a href="searx.settings.html" title="next chapter">Settings Loader</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.search.processors.rst.txt"
|
||||
rel="nofollow">Show Source</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright SearXNG team.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
209
src/searx.settings.html
Normal file
209
src/searx.settings.html
Normal file
@@ -0,0 +1,209 @@
|
||||
<!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>Settings Loader — SearXNG Documentation (2025.4.11+2287a6826)</title>
|
||||
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=6625fa76" />
|
||||
<link rel="stylesheet" type="text/css" href="../_static/searxng.css?v=52e4ff28" />
|
||||
<script src="../_static/documentation_options.js?v=725693a2"></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.4.11+2287a6826" 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="next" title="SQLite DB" href="searx.sqlitedb.html" />
|
||||
<link rel="prev" title="Search processors" href="searx.search.processors.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="N">next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="searx.search.processors.html" title="Search processors"
|
||||
accesskey="P">previous</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../index.html">SearXNG Documentation (2025.4.11+2287a6826)</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Source-Code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">Settings Loader</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<section id="module-searx.settings_loader">
|
||||
<span id="settings-loader"></span><span id="searx-settings-loader"></span><h1>Settings Loader<a class="headerlink" href="#module-searx.settings_loader" title="Link to this heading">¶</a></h1>
|
||||
<p>Implementations for loading configurations from YAML files. This essentially
|
||||
includes the configuration of the (<a class="reference internal" href="../admin/settings/index.html#searxng-settings-yml"><span class="std std-ref">SearXNG appl</span></a>)
|
||||
server. The default configuration for the application server is loaded from the
|
||||
<a class="extlink-origin reference external" href="https://github.com/searxng/searxng/blob/master/searx/settings.yml">DEFAULT_SETTINGS_FILE</a>. This default
|
||||
configuration can be completely replaced or <a class="reference internal" href="../admin/installation-searxng.html#use-default-settings-yml"><span class="std std-ref">customized individually</span></a> and the <code class="docutils literal notranslate"><span class="pre">SEARXNG_SETTINGS_PATH</span></code> environment
|
||||
variable can be used to set the location from which the local customizations are
|
||||
to be loaded. The rules used for this can be found in the
|
||||
<a class="reference internal" href="#searx.settings_loader.get_user_cfg_folder" title="searx.settings_loader.get_user_cfg_folder"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_user_cfg_folder</span></code></a> function.</p>
|
||||
<ul class="simple">
|
||||
<li><p>By default, local configurations are expected in folder <code class="docutils literal notranslate"><span class="pre">/etc/searxng</span></code> from
|
||||
where applications can load them with the <a class="reference internal" href="#searx.settings_loader.get_yaml_cfg" title="searx.settings_loader.get_yaml_cfg"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_yaml_cfg</span></code></a> function.</p></li>
|
||||
<li><p>By default, customized <a class="reference internal" href="../admin/settings/index.html#searxng-settings-yml"><span class="std std-ref">SearXNG appl</span></a> settings are
|
||||
expected in a file named <code class="docutils literal notranslate"><span class="pre">settings.yml</span></code>.</p></li>
|
||||
</ul>
|
||||
<dl class="py data">
|
||||
<dt class="sig sig-object py" id="searx.settings_loader.DEFAULT_SETTINGS_FILE">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.settings_loader.</span></span><span class="sig-name descname"><span class="pre">DEFAULT_SETTINGS_FILE</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">PosixPath('/home/runner/work/searxng/searxng/searx/settings.yml')</span></em><a class="headerlink" href="#searx.settings_loader.DEFAULT_SETTINGS_FILE" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>The <a class="extlink-origin reference external" href="https://github.com/searxng/searxng/blob/master/searx/settings.yml">git://searx/settings.yml</a> file with all the default settings.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.settings_loader.load_yaml">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.settings_loader.</span></span><span class="sig-name descname"><span class="pre">load_yaml</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">file_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 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/pathlib.html#pathlib.Path" title="(in Python v3.13)"><span class="pre">Path</span></a></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/settings_loader.html#load_yaml"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.settings_loader.load_yaml" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Load YAML config from a file.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.settings_loader.get_yaml_cfg">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.settings_loader.</span></span><span class="sig-name descname"><span class="pre">get_yaml_cfg</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">file_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 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/pathlib.html#pathlib.Path" title="(in Python v3.13)"><span class="pre">Path</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.13)"><span class="pre">dict</span></a></span></span><a class="reference internal" href="../_modules/searx/settings_loader.html#get_yaml_cfg"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.settings_loader.get_yaml_cfg" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Shortcut to load a YAML config from a file, located in the</p>
|
||||
<ul class="simple">
|
||||
<li><p><a class="reference internal" href="#searx.settings_loader.get_user_cfg_folder" title="searx.settings_loader.get_user_cfg_folder"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_user_cfg_folder</span></code></a> or</p></li>
|
||||
<li><p>in the <code class="docutils literal notranslate"><span class="pre">searx</span></code> folder of the SearXNG installation</p></li>
|
||||
</ul>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.settings_loader.get_user_cfg_folder">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.settings_loader.</span></span><span class="sig-name descname"><span class="pre">get_user_cfg_folder</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/pathlib.html#pathlib.Path" title="(in Python v3.13)"><span class="pre">Path</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/settings_loader.html#get_user_cfg_folder"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.settings_loader.get_user_cfg_folder" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Returns folder where the local configurations are located.</p>
|
||||
<ol class="arabic">
|
||||
<li><p>If the <code class="docutils literal notranslate"><span class="pre">SEARXNG_SETTINGS_PATH</span></code> environment is set and points to a
|
||||
folder (e.g. <code class="docutils literal notranslate"><span class="pre">/etc/mysxng/</span></code>), all local configurations are expected in
|
||||
this folder. The settings of the <a class="reference internal" href="../admin/settings/index.html#searxng-settings-yml"><span class="std std-ref">SearXNG appl</span></a> then expected in <code class="docutils literal notranslate"><span class="pre">settings.yml</span></code>
|
||||
(e.g. <code class="docutils literal notranslate"><span class="pre">/etc/mysxng/settings.yml</span></code>).</p></li>
|
||||
<li><p>If the <code class="docutils literal notranslate"><span class="pre">SEARXNG_SETTINGS_PATH</span></code> environment is set and points to a file
|
||||
(e.g. <code class="docutils literal notranslate"><span class="pre">/etc/mysxng/myinstance.yml</span></code>), this file contains the settings of
|
||||
the <a class="reference internal" href="../admin/settings/index.html#searxng-settings-yml"><span class="std std-ref">SearXNG appl</span></a> and the folder
|
||||
(e.g. <code class="docutils literal notranslate"><span class="pre">/etc/mysxng/</span></code>) is used for all other configurations.</p>
|
||||
<p>This type (<code class="docutils literal notranslate"><span class="pre">SEARXNG_SETTINGS_PATH</span></code> points to a file) is suitable for
|
||||
use cases in which different profiles of the <a class="reference internal" href="../admin/settings/index.html#searxng-settings-yml"><span class="std std-ref">SearXNG appl</span></a> are to be managed, such as in test scenarios.</p>
|
||||
</li>
|
||||
<li><p>If folder <code class="docutils literal notranslate"><span class="pre">/etc/searxng</span></code> exists, it is used.</p></li>
|
||||
</ol>
|
||||
<p>In case none of the above path exists, <code class="docutils literal notranslate"><span class="pre">None</span></code> is returned. In case of
|
||||
environment <code class="docutils literal notranslate"><span class="pre">SEARXNG_SETTINGS_PATH</span></code> is set, but the (folder or file) does
|
||||
not exists, a <a class="reference external" href="https://docs.python.org/3/library/exceptions.html#EnvironmentError" title="(in Python v3.13)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">EnvironmentError</span></code></a> is raised.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.settings_loader.load_settings">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.settings_loader.</span></span><span class="sig-name descname"><span class="pre">load_settings</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">load_user_settings</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#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/stdtypes.html#dict" title="(in Python v3.13)"><span class="pre">dict</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></span><a class="reference internal" href="../_modules/searx/settings_loader.html#load_settings"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.settings_loader.load_settings" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Function for loading the settings of the SearXNG application
|
||||
(<a class="reference internal" href="../admin/settings/index.html#searxng-settings-yml"><span class="std std-ref">settings.yml</span></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.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 current"><a class="current reference internal" href="#">Settings Loader</a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.settings_loader.DEFAULT_SETTINGS_FILE"><code class="docutils literal notranslate"><span class="pre">DEFAULT_SETTINGS_FILE</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.settings_loader.load_yaml"><code class="docutils literal notranslate"><span class="pre">load_yaml()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.settings_loader.get_yaml_cfg"><code class="docutils literal notranslate"><span class="pre">get_yaml_cfg()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.settings_loader.get_user_cfg_folder"><code class="docutils literal notranslate"><span class="pre">get_user_cfg_folder()</span></code></a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.settings_loader.load_settings"><code class="docutils literal notranslate"><span class="pre">load_settings()</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.sqlitedb.html">SQLite DB</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.utils.html">Utility functions for the engines</a></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.search.processors.html" title="previous chapter">Search processors</a>
|
||||
<li>Next: <a href="searx.sqlitedb.html" title="next 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.settings.rst.txt"
|
||||
rel="nofollow">Show Source</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright SearXNG team.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
341
src/searx.sqlitedb.html
Normal file
341
src/searx.sqlitedb.html
Normal file
@@ -0,0 +1,341 @@
|
||||
<!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>SQLite DB — SearXNG Documentation (2025.4.11+2287a6826)</title>
|
||||
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=6625fa76" />
|
||||
<link rel="stylesheet" type="text/css" href="../_static/searxng.css?v=52e4ff28" />
|
||||
<script src="../_static/documentation_options.js?v=725693a2"></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.4.11+2287a6826" 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="next" title="Utility functions for the engines" href="searx.utils.html" />
|
||||
<link rel="prev" title="Settings Loader" href="searx.settings.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.utils.html" title="Utility functions for the engines"
|
||||
accesskey="N">next</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="searx.settings.html" title="Settings Loader"
|
||||
accesskey="P">previous</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../index.html">SearXNG Documentation (2025.4.11+2287a6826)</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Source-Code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">SQLite DB</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<section id="sqlite-db">
|
||||
<span id="id1"></span><h1>SQLite DB<a class="headerlink" href="#sqlite-db" title="Link to this heading">¶</a></h1>
|
||||
<p id="module-searx.sqlitedb">Implementations to make access to SQLite databases a little more convenient.</p>
|
||||
<dl class="simple">
|
||||
<dt><a class="reference internal" href="#searx.sqlitedb.SQLiteAppl" title="searx.sqlitedb.SQLiteAppl"><code class="xref py py-obj docutils literal notranslate"><span class="pre">SQLiteAppl</span></code></a></dt><dd><p>Abstract class with which DB applications can be implemented.</p>
|
||||
</dd>
|
||||
<dt><a class="reference internal" href="#searx.sqlitedb.SQLiteProperties" title="searx.sqlitedb.SQLiteProperties"><code class="xref py py-obj docutils literal notranslate"><span class="pre">SQLiteProperties</span></code></a>:</dt><dd><p>Class to manage properties stored in a database.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr class="docutils" />
|
||||
<dl class="py class">
|
||||
<dt class="sig sig-object py" id="searx.sqlitedb.SQLiteAppl">
|
||||
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">searx.sqlitedb.</span></span><span class="sig-name descname"><span class="pre">SQLiteAppl</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">db_url</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/sqlitedb.html#SQLiteAppl"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.sqlitedb.SQLiteAppl" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Abstract base class for implementing convenient DB access in SQLite
|
||||
applications. In the constructor, a <a class="reference internal" href="#searx.sqlitedb.SQLiteProperties" title="searx.sqlitedb.SQLiteProperties"><code class="xref py py-obj docutils literal notranslate"><span class="pre">SQLiteProperties</span></code></a> instance is
|
||||
already aggregated under <code class="docutils literal notranslate"><span class="pre">self.properties</span></code>.</p>
|
||||
<dl class="py attribute">
|
||||
<dt class="sig sig-object py" id="searx.sqlitedb.SQLiteAppl.DB_SCHEMA">
|
||||
<span class="sig-name descname"><span class="pre">DB_SCHEMA</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><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></em><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">1</span></em><a class="headerlink" href="#searx.sqlitedb.SQLiteAppl.DB_SCHEMA" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>As soon as changes are made to the DB schema, the version number must be
|
||||
increased. Changes to the version number require the DB to be recreated (or
|
||||
migrated / if an migration path exists and is implemented).</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py attribute">
|
||||
<dt class="sig sig-object py" id="searx.sqlitedb.SQLiteAppl.SQLITE_THREADING_MODE">
|
||||
<span class="sig-name descname"><span class="pre">SQLITE_THREADING_MODE</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">'serialized'</span></em><a class="headerlink" href="#searx.sqlitedb.SQLiteAppl.SQLITE_THREADING_MODE" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Threading mode of the SQLite library. Depends on the options used at
|
||||
compile time and is different for different distributions and architectures.</p>
|
||||
<p>Possible values are 0:<code class="docutils literal notranslate"><span class="pre">single-thread</span></code>, 1:<code class="docutils literal notranslate"><span class="pre">multi-thread</span></code>,
|
||||
3:<code class="docutils literal notranslate"><span class="pre">serialized</span></code> (see <a class="reference external" href="https://docs.python.org/3/library/sqlite3.html#sqlite3.threadsafety" title="(in Python v3.13)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">sqlite3.threadsafety</span></code></a>). Pre- Python 3.11
|
||||
this value was hard coded to 1.</p>
|
||||
<p>Depending on this value, optimizations are made, e.g. in “serialized” mode
|
||||
it is not necessary to create a separate DB connector for each thread.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py attribute">
|
||||
<dt class="sig sig-object py" id="searx.sqlitedb.SQLiteAppl.SQLITE_CONNECT_ARGS">
|
||||
<span class="sig-name descname"><span class="pre">SQLITE_CONNECT_ARGS</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">{'autocommit':</span> <span class="pre">False,</span> <span class="pre">'cached_statements':</span> <span class="pre">0,</span> <span class="pre">'check_same_thread':</span> <span class="pre">False}</span></em><a class="headerlink" href="#searx.sqlitedb.SQLiteAppl.SQLITE_CONNECT_ARGS" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Connection arguments (<a class="reference external" href="https://docs.python.org/3/library/sqlite3.html#sqlite3.connect" title="(in Python v3.13)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">sqlite3.connect</span></code></a>)</p>
|
||||
<dl>
|
||||
<dt><code class="docutils literal notranslate"><span class="pre">check_same_thread</span></code>:</dt><dd><p>Is disabled by default when <a class="reference internal" href="#searx.sqlitedb.SQLiteAppl.SQLITE_THREADING_MODE" title="searx.sqlitedb.SQLiteAppl.SQLITE_THREADING_MODE"><code class="xref py py-obj docutils literal notranslate"><span class="pre">SQLITE_THREADING_MODE</span></code></a> is
|
||||
<code class="docutils literal notranslate"><span class="pre">serialized</span></code>. The check is more of a hindrance in this case because it
|
||||
would prevent a DB connector from being used in multiple threads.</p>
|
||||
</dd>
|
||||
<dt><code class="docutils literal notranslate"><span class="pre">autocommit</span></code>:</dt><dd><p>Is disabled by default. Note: autocommit option has been added in Python
|
||||
3.12.</p>
|
||||
</dd>
|
||||
<dt><code class="docutils literal notranslate"><span class="pre">cached_statements</span></code>:</dt><dd><p>Is set to <code class="docutils literal notranslate"><span class="pre">0</span></code> by default. Note: Python 3.12+ fetch result are not
|
||||
consistent in multi-threading application and causing an API misuse error.</p>
|
||||
<p>The multithreading use in SQLiteAppl is intended and supported if
|
||||
threadsafety is set to 3 (aka “serialized”). CPython supports “serialized”
|
||||
from version 3.12 on, but unfortunately only with errors:</p>
|
||||
<ul class="simple">
|
||||
<li><p><a class="reference external" href="https://github.com/python/cpython/issues/118172">https://github.com/python/cpython/issues/118172</a></p></li>
|
||||
<li><p><a class="reference external" href="https://github.com/python/cpython/issues/123873">https://github.com/python/cpython/issues/123873</a></p></li>
|
||||
</ul>
|
||||
<p>The workaround for SQLite3 multithreading cache inconsistency ist to set
|
||||
option <code class="docutils literal notranslate"><span class="pre">cached_statements</span></code> to <code class="docutils literal notranslate"><span class="pre">0</span></code> by default.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.sqlitedb.SQLiteAppl.connect">
|
||||
<span class="sig-name descname"><span class="pre">connect</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/sqlite3.html#sqlite3.Connection" title="(in Python v3.13)"><span class="pre">Connection</span></a></span></span><a class="reference internal" href="../_modules/searx/sqlitedb.html#SQLiteAppl.connect"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.sqlitedb.SQLiteAppl.connect" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Creates a new DB connection (<a class="reference internal" href="#searx.sqlitedb.SQLiteAppl.SQLITE_CONNECT_ARGS" title="searx.sqlitedb.SQLiteAppl.SQLITE_CONNECT_ARGS"><code class="xref py py-obj docutils literal notranslate"><span class="pre">SQLITE_CONNECT_ARGS</span></code></a>). If not
|
||||
already done, the DB schema is set up</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.sqlitedb.SQLiteAppl.register_functions">
|
||||
<span class="sig-name descname"><span class="pre">register_functions</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">conn</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/sqlitedb.html#SQLiteAppl.register_functions"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.sqlitedb.SQLiteAppl.register_functions" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Create <a class="reference external" href="https://docs.python.org/3/library/sqlite3.html#sqlite3.Connection.create_function">user-defined</a> SQL functions.</p>
|
||||
<dl>
|
||||
<dt><code class="docutils literal notranslate"><span class="pre">REGEXP(<pattern>,</span> <span class="pre"><field>)</span></code><span class="classifier">0 | 1</span></dt><dd><p><a class="reference external" href="https://docs.python.org/3/library/re.html#re.search">re.search</a> returns (int) 1 for a match and 0 for none match of
|
||||
<code class="docutils literal notranslate"><span class="pre"><pattern></span></code> in <code class="docutils literal notranslate"><span class="pre"><field></span></code>.</p>
|
||||
<div class="highlight-sql notranslate"><div class="highlight"><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="s1">'12'</span><span class="w"> </span><span class="k">AS</span><span class="w"> </span><span class="n">field</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="n">REGEXP</span><span class="p">(</span><span class="s1">'^[0-9][0-9]$'</span><span class="p">,</span><span class="w"> </span><span class="n">field</span><span class="p">)</span>
|
||||
<span class="c1">-- 12</span>
|
||||
|
||||
<span class="k">SELECT</span><span class="w"> </span><span class="n">REGEXP</span><span class="p">(</span><span class="s1">'[0-9][0-9]'</span><span class="p">,</span><span class="w"> </span><span class="s1">'X12Y'</span><span class="p">)</span>
|
||||
<span class="c1">-- 1</span>
|
||||
<span class="k">SELECT</span><span class="w"> </span><span class="n">REGEXP</span><span class="p">(</span><span class="s1">'[0-9][0-9]'</span><span class="p">,</span><span class="w"> </span><span class="s1">'X1Y'</span><span class="p">)</span>
|
||||
<span class="c1">-- 0</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py property">
|
||||
<dt class="sig sig-object py" id="searx.sqlitedb.SQLiteAppl.DB">
|
||||
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">DB</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><a class="reference external" href="https://docs.python.org/3/library/sqlite3.html#sqlite3.Connection" title="(in Python v3.13)"><span class="pre">Connection</span></a></em><a class="headerlink" href="#searx.sqlitedb.SQLiteAppl.DB" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Provides a DB connection. The connection is a <em>singleton</em> and
|
||||
therefore well suited for read access. If
|
||||
<a class="reference internal" href="#searx.sqlitedb.SQLiteAppl.SQLITE_THREADING_MODE" title="searx.sqlitedb.SQLiteAppl.SQLITE_THREADING_MODE"><code class="xref py py-obj docutils literal notranslate"><span class="pre">SQLITE_THREADING_MODE</span></code></a> is <code class="docutils literal notranslate"><span class="pre">serialized</span></code> only one DB connection
|
||||
is created for all threads.</p>
|
||||
<div class="admonition note">
|
||||
<p class="admonition-title">Note</p>
|
||||
<p>For dedicated <a class="reference external" href="https://docs.python.org/3/library/sqlite3.html#sqlite3-controlling-transactions">transaction control</a>, it is recommended to create a
|
||||
new connection (<a class="reference internal" href="#searx.sqlitedb.SQLiteAppl.connect" title="searx.sqlitedb.SQLiteAppl.connect"><code class="xref py py-obj docutils literal notranslate"><span class="pre">SQLiteAppl.connect</span></code></a>).</p>
|
||||
</div>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.sqlitedb.SQLiteAppl.init">
|
||||
<span class="sig-name descname"><span class="pre">init</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/sqlitedb.html#SQLiteAppl.init"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.sqlitedb.SQLiteAppl.init" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Initializes the DB schema and properties, is only executed once even
|
||||
if called several times.</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py class">
|
||||
<dt class="sig sig-object py" id="searx.sqlitedb.SQLiteProperties">
|
||||
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">searx.sqlitedb.</span></span><span class="sig-name descname"><span class="pre">SQLiteProperties</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">db_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><a class="reference internal" href="../_modules/searx/sqlitedb.html#SQLiteProperties"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.sqlitedb.SQLiteProperties" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Simple class to manage properties of a DB application in the DB. The
|
||||
object has its own DB connection and transaction area.</p>
|
||||
<div class="highlight-sql notranslate"><div class="highlight"><pre><span></span><span class="k">CREATE</span><span class="w"> </span><span class="k">TABLE</span><span class="w"> </span><span class="k">IF</span><span class="w"> </span><span class="k">NOT</span><span class="w"> </span><span class="k">EXISTS</span><span class="w"> </span><span class="n">properties</span><span class="w"> </span><span class="p">(</span>
|
||||
<span class="w"> </span><span class="n">name</span><span class="w"> </span><span class="nb">TEXT</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="n">value</span><span class="w"> </span><span class="nb">TEXT</span><span class="p">,</span>
|
||||
<span class="w"> </span><span class="n">m_time</span><span class="w"> </span><span class="nb">INTEGER</span><span class="w"> </span><span class="k">DEFAULT</span><span class="w"> </span><span class="p">(</span><span class="n">strftime</span><span class="p">(</span><span class="s1">'%s'</span><span class="p">,</span><span class="w"> </span><span class="s1">'now'</span><span class="p">)),</span>
|
||||
<span class="w"> </span><span class="k">PRIMARY</span><span class="w"> </span><span class="k">KEY</span><span class="w"> </span><span class="p">(</span><span class="n">name</span><span class="p">))</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<dl class="py attribute">
|
||||
<dt class="sig sig-object py" id="searx.sqlitedb.SQLiteProperties.DDL_PROPERTIES">
|
||||
<span class="sig-name descname"><span class="pre">DDL_PROPERTIES</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">"CREATE</span> <span class="pre">TABLE</span> <span class="pre">IF</span> <span class="pre">NOT</span> <span class="pre">EXISTS</span> <span class="pre">properties</span> <span class="pre">(\n</span>  <span class="pre">name</span>       <span class="pre">TEXT,\n</span>  <span class="pre">value</span>      <span class="pre">TEXT,\n</span>  <span class="pre">m_time</span>     <span class="pre">INTEGER</span> <span class="pre">DEFAULT</span> <span class="pre">(strftime('%s',</span> <span class="pre">'now')),</span>  <span class="pre">--</span> <span class="pre">last</span> <span class="pre">modified</span> <span class="pre">(unix</span> <span class="pre">epoch)</span> <span class="pre">time</span> <span class="pre">in</span> <span class="pre">sec.\n</span>  <span class="pre">PRIMARY</span> <span class="pre">KEY</span> <span class="pre">(name))"</span></em><a class="headerlink" href="#searx.sqlitedb.SQLiteProperties.DDL_PROPERTIES" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Table to store properties of the DB application</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py attribute">
|
||||
<dt class="sig sig-object py" id="searx.sqlitedb.SQLiteProperties.SQLITE_CONNECT_ARGS">
|
||||
<span class="sig-name descname"><span class="pre">SQLITE_CONNECT_ARGS</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">{'autocommit':</span> <span class="pre">True,</span> <span class="pre">'cached_statements':</span> <span class="pre">0,</span> <span class="pre">'check_same_thread':</span> <span class="pre">False}</span></em><a class="headerlink" href="#searx.sqlitedb.SQLiteProperties.SQLITE_CONNECT_ARGS" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Connection arguments (<a class="reference external" href="https://docs.python.org/3/library/sqlite3.html#sqlite3.connect" title="(in Python v3.13)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">sqlite3.connect</span></code></a>)</p>
|
||||
<dl>
|
||||
<dt><code class="docutils literal notranslate"><span class="pre">check_same_thread</span></code>:</dt><dd><p>Is disabled by default when <code class="xref py py-obj docutils literal notranslate"><span class="pre">SQLITE_THREADING_MODE</span></code> is
|
||||
<code class="docutils literal notranslate"><span class="pre">serialized</span></code>. The check is more of a hindrance in this case because it
|
||||
would prevent a DB connector from being used in multiple threads.</p>
|
||||
</dd>
|
||||
<dt><code class="docutils literal notranslate"><span class="pre">autocommit</span></code>:</dt><dd><p>Is disabled by default. Note: autocommit option has been added in Python
|
||||
3.12.</p>
|
||||
</dd>
|
||||
<dt><code class="docutils literal notranslate"><span class="pre">cached_statements</span></code>:</dt><dd><p>Is set to <code class="docutils literal notranslate"><span class="pre">0</span></code> by default. Note: Python 3.12+ fetch result are not
|
||||
consistent in multi-threading application and causing an API misuse error.</p>
|
||||
<p>The multithreading use in SQLiteAppl is intended and supported if
|
||||
threadsafety is set to 3 (aka “serialized”). CPython supports “serialized”
|
||||
from version 3.12 on, but unfortunately only with errors:</p>
|
||||
<ul class="simple">
|
||||
<li><p><a class="reference external" href="https://github.com/python/cpython/issues/118172">https://github.com/python/cpython/issues/118172</a></p></li>
|
||||
<li><p><a class="reference external" href="https://github.com/python/cpython/issues/123873">https://github.com/python/cpython/issues/123873</a></p></li>
|
||||
</ul>
|
||||
<p>The workaround for SQLite3 multithreading cache inconsistency ist to set
|
||||
option <code class="docutils literal notranslate"><span class="pre">cached_statements</span></code> to <code class="docutils literal notranslate"><span class="pre">0</span></code> by default.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.sqlitedb.SQLiteProperties.init">
|
||||
<span class="sig-name descname"><span class="pre">init</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/sqlitedb.html#SQLiteProperties.init"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.sqlitedb.SQLiteProperties.init" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Initializes DB schema of the properties in the DB.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.sqlitedb.SQLiteProperties.set">
|
||||
<span class="sig-name descname"><span class="pre">set</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/sqlitedb.html#SQLiteProperties.set"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.sqlitedb.SQLiteProperties.set" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Set <code class="docutils literal notranslate"><span class="pre">value</span></code> of property <code class="docutils literal notranslate"><span class="pre">name</span></code> in DB. If property already
|
||||
exists, update the <code class="docutils literal notranslate"><span class="pre">m_time</span></code> (and the value).</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.sqlitedb.SQLiteProperties.row">
|
||||
<span class="sig-name descname"><span class="pre">row</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">default</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/sqlitedb.html#SQLiteProperties.row"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.sqlitedb.SQLiteProperties.row" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Returns the DB row of property <code class="docutils literal notranslate"><span class="pre">name</span></code> or <code class="docutils literal notranslate"><span class="pre">default</span></code> if property
|
||||
not exists in DB.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="searx.sqlitedb.SQLiteProperties.m_time">
|
||||
<span class="sig-name descname"><span class="pre">m_time</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></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/functions.html#int" title="(in Python v3.13)"><span class="pre">int</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</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</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/sqlitedb.html#SQLiteProperties.m_time"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.sqlitedb.SQLiteProperties.m_time" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Last modification time of this property.</p>
|
||||
</dd></dl>
|
||||
|
||||
</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.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 current"><a class="current reference internal" href="#">SQLite DB</a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.sqlitedb.SQLiteAppl"><code class="docutils literal notranslate"><span class="pre">SQLiteAppl</span></code></a><ul>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.sqlitedb.SQLiteAppl.DB_SCHEMA"><code class="docutils literal notranslate"><span class="pre">SQLiteAppl.DB_SCHEMA</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.sqlitedb.SQLiteAppl.SQLITE_THREADING_MODE"><code class="docutils literal notranslate"><span class="pre">SQLiteAppl.SQLITE_THREADING_MODE</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.sqlitedb.SQLiteAppl.SQLITE_CONNECT_ARGS"><code class="docutils literal notranslate"><span class="pre">SQLiteAppl.SQLITE_CONNECT_ARGS</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.sqlitedb.SQLiteAppl.connect"><code class="docutils literal notranslate"><span class="pre">SQLiteAppl.connect()</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.sqlitedb.SQLiteAppl.register_functions"><code class="docutils literal notranslate"><span class="pre">SQLiteAppl.register_functions()</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.sqlitedb.SQLiteAppl.DB"><code class="docutils literal notranslate"><span class="pre">SQLiteAppl.DB</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.sqlitedb.SQLiteAppl.init"><code class="docutils literal notranslate"><span class="pre">SQLiteAppl.init()</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#searx.sqlitedb.SQLiteProperties"><code class="docutils literal notranslate"><span class="pre">SQLiteProperties</span></code></a><ul>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.sqlitedb.SQLiteProperties.DDL_PROPERTIES"><code class="docutils literal notranslate"><span class="pre">SQLiteProperties.DDL_PROPERTIES</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.sqlitedb.SQLiteProperties.SQLITE_CONNECT_ARGS"><code class="docutils literal notranslate"><span class="pre">SQLiteProperties.SQLITE_CONNECT_ARGS</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.sqlitedb.SQLiteProperties.init"><code class="docutils literal notranslate"><span class="pre">SQLiteProperties.init()</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.sqlitedb.SQLiteProperties.set"><code class="docutils literal notranslate"><span class="pre">SQLiteProperties.set()</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.sqlitedb.SQLiteProperties.row"><code class="docutils literal notranslate"><span class="pre">SQLiteProperties.row()</span></code></a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#searx.sqlitedb.SQLiteProperties.m_time"><code class="docutils literal notranslate"><span class="pre">SQLiteProperties.m_time()</span></code></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="searx.utils.html">Utility functions for the engines</a></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.settings.html" title="previous chapter">Settings Loader</a>
|
||||
<li>Next: <a href="searx.utils.html" title="next chapter">Utility functions for the engines</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.sqlitedb.rst.txt"
|
||||
rel="nofollow">Show Source</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright SearXNG team.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
636
src/searx.utils.html
Normal file
636
src/searx.utils.html
Normal file
@@ -0,0 +1,636 @@
|
||||
<!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 — SearXNG Documentation (2025.4.11+2287a6826)</title>
|
||||
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=6625fa76" />
|
||||
<link rel="stylesheet" type="text/css" href="../_static/searxng.css?v=52e4ff28" />
|
||||
<script src="../_static/documentation_options.js?v=725693a2"></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.4.11+2287a6826" 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.4.11+2287a6826)</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Source-Code</a> »</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 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">'eu',</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">'is',</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>
|
||||
|
||||
<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">→</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.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">→</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.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">→</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">>>> </span><span class="n">html_to_text</span><span class="p">(</span><span class="s1">'Example <span id="42">#2</span>'</span><span class="p">)</span>
|
||||
<span class="go">'Example #2'</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">html_to_text</span><span class="p">(</span><span class="s1">'<style>.span { color: red; }</style><span>Example</span>'</span><span class="p">)</span>
|
||||
<span class="go">'Example'</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">html_to_text</span><span class="p">(</span><span class="sa">r</span><span class="s1">'regexp: (?<![a-zA-Z]'</span><span class="p">)</span>
|
||||
<span class="go">'regexp: (?<![a-zA-Z]'</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</dd>
|
||||
</dl>
|
||||
</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">→</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">>>> </span><span class="n">markdown_to_text</span><span class="p">(</span><span class="s1">'[example](https://example.com)'</span><span class="p">)</span>
|
||||
<span class="go">'example'</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">markdown_to_text</span><span class="p">(</span><span class="s1">'## Headline'</span><span class="p">)</span>
|
||||
<span class="go">'Headline'</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">→</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.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">→</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">>>> </span><span class="n">normalize_url</span><span class="p">(</span><span class="s1">'https://example.com'</span><span class="p">,</span> <span class="s1">'http://example.com/'</span><span class="p">)</span>
|
||||
<span class="go">'https://example.com/'</span>
|
||||
<span class="gp">>>> </span><span class="n">normalize_url</span><span class="p">(</span><span class="s1">'//example.com'</span><span class="p">,</span> <span class="s1">'http://example.com/'</span><span class="p">)</span>
|
||||
<span class="go">'http://example.com/'</span>
|
||||
<span class="gp">>>> </span><span class="n">normalize_url</span><span class="p">(</span><span class="s1">'//example.com'</span><span class="p">,</span> <span class="s1">'https://example.com/'</span><span class="p">)</span>
|
||||
<span class="go">'https://example.com/'</span>
|
||||
<span class="gp">>>> </span><span class="n">normalize_url</span><span class="p">(</span><span class="s1">'/path?a=1'</span><span class="p">,</span> <span class="s1">'https://example.com'</span><span class="p">)</span>
|
||||
<span class="go">'https://example.com/path?a=1'</span>
|
||||
<span class="gp">>>> </span><span class="n">normalize_url</span><span class="p">(</span><span class="s1">''</span><span class="p">,</span> <span class="s1">'https://example.com'</span><span class="p">)</span>
|
||||
<span class="go">'https://example.com/'</span>
|
||||
<span class="gp">>>> </span><span class="n">normalize_url</span><span class="p">(</span><span class="s1">'/test'</span><span class="p">,</span> <span class="s1">'/path'</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.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">→</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">>>> </span><span class="k">def</span><span class="w"> </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">>>> </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">>>> </span><span class="n">f</span><span class="p">(</span><span class="s1">'<span id="42">https://example.com</span>'</span><span class="p">,</span> <span class="s1">'http://example.com/'</span><span class="p">)</span>
|
||||
<span class="go">'https://example.com/'</span>
|
||||
<span class="gp">>>> </span><span class="n">f</span><span class="p">(</span><span class="s1">'https://example.com'</span><span class="p">,</span> <span class="s1">'http://example.com/'</span><span class="p">)</span>
|
||||
<span class="go">'https://example.com/'</span>
|
||||
<span class="gp">>>> </span><span class="n">f</span><span class="p">(</span><span class="s1">'//example.com'</span><span class="p">,</span> <span class="s1">'http://example.com/'</span><span class="p">)</span>
|
||||
<span class="go">'http://example.com/'</span>
|
||||
<span class="gp">>>> </span><span class="n">f</span><span class="p">(</span><span class="s1">'//example.com'</span><span class="p">,</span> <span class="s1">'https://example.com/'</span><span class="p">)</span>
|
||||
<span class="go">'https://example.com/'</span>
|
||||
<span class="gp">>>> </span><span class="n">f</span><span class="p">(</span><span class="s1">'/path?a=1'</span><span class="p">,</span> <span class="s1">'https://example.com'</span><span class="p">)</span>
|
||||
<span class="go">'https://example.com/path?a=1'</span>
|
||||
<span class="gp">>>> </span><span class="n">f</span><span class="p">(</span><span class="s1">''</span><span class="p">,</span> <span class="s1">'https://example.com'</span><span class="p">)</span>
|
||||
<span class="go">raise lxml.etree.ParserError</span>
|
||||
<span class="gp">>>> </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">'https://example.com'</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.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">→</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">>>> </span><span class="n">dict_subset</span><span class="p">({</span><span class="s1">'A'</span><span class="p">:</span> <span class="s1">'a'</span><span class="p">,</span> <span class="s1">'B'</span><span class="p">:</span> <span class="s1">'b'</span><span class="p">,</span> <span class="s1">'C'</span><span class="p">:</span> <span class="s1">'c'</span><span class="p">},</span> <span class="p">[</span><span class="s1">'A'</span><span class="p">,</span> <span class="s1">'C'</span><span class="p">])</span>
|
||||
<span class="go">{'A': 'a', 'C': 'c'}</span>
|
||||
<span class="gp">>>> </span><span class="o">>></span> <span class="n">dict_subset</span><span class="p">({</span><span class="s1">'A'</span><span class="p">:</span> <span class="s1">'a'</span><span class="p">,</span> <span class="s1">'B'</span><span class="p">:</span> <span class="s1">'b'</span><span class="p">,</span> <span class="s1">'C'</span><span class="p">:</span> <span class="s1">'c'</span><span class="p">},</span> <span class="p">[</span><span class="s1">'A'</span><span class="p">,</span> <span class="s1">'D'</span><span class="p">])</span>
|
||||
<span class="go">{'A': 'a'}</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.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">→</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.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">>>> </span><span class="n">extr</span><span class="p">(</span><span class="s2">"abcde"</span><span class="p">,</span> <span class="s2">"a"</span><span class="p">,</span> <span class="s2">"e"</span><span class="p">)</span>
|
||||
<span class="go">"bcd"</span>
|
||||
<span class="gp">>>> </span><span class="n">extr</span><span class="p">(</span><span class="s2">"abcde"</span><span class="p">,</span> <span class="s2">"a"</span><span class="p">,</span> <span class="s2">"z"</span><span class="p">,</span> <span class="n">deafult</span><span class="o">=</span><span class="s2">"nothing"</span><span class="p">)</span>
|
||||
<span class="go">"nothing"</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</dd>
|
||||
</dl>
|
||||
</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">→</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">→</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">>>> </span><span class="n">is_valid_lang</span><span class="p">(</span><span class="s1">'zz'</span><span class="p">)</span>
|
||||
<span class="go">None</span>
|
||||
<span class="gp">>>> </span><span class="n">is_valid_lang</span><span class="p">(</span><span class="s1">'uk'</span><span class="p">)</span>
|
||||
<span class="go">(True, 'uk', 'ukrainian')</span>
|
||||
<span class="gp">>>> </span><span class="n">is_valid_lang</span><span class="p">(</span><span class="sa">b</span><span class="s1">'uk'</span><span class="p">)</span>
|
||||
<span class="go">(True, 'uk', 'ukrainian')</span>
|
||||
<span class="gp">>>> </span><span class="n">is_valid_lang</span><span class="p">(</span><span class="s1">'en'</span><span class="p">)</span>
|
||||
<span class="go">(True, 'en', 'english')</span>
|
||||
<span class="gp">>>> </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">'Español'</span><span class="p">)</span>
|
||||
<span class="go">(True, 'es', 'spanish')</span>
|
||||
<span class="gp">>>> </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">'Spanish'</span><span class="p">)</span>
|
||||
<span class="go">(True, 'es', 'spanish')</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</dd>
|
||||
</dl>
|
||||
</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">→</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 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">→</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">>>> </span><span class="n">ecma_unescape</span><span class="p">(</span><span class="s1">'</span><span class="si">%u</span><span class="s1">5409'</span><span class="p">)</span>
|
||||
<span class="go">'吉'</span>
|
||||
<span class="gp">>>> </span><span class="n">ecma_unescape</span><span class="p">(</span><span class="s1">'%20'</span><span class="p">)</span>
|
||||
<span class="go">' '</span>
|
||||
<span class="gp">>>> </span><span class="n">ecma_unescape</span><span class="p">(</span><span class="s1">'</span><span class="si">%F</span><span class="s1">3'</span><span class="p">)</span>
|
||||
<span class="go">'ó'</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py function">
|
||||
<dt class="sig sig-object py" id="searx.utils.remove_pua_from_str">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.utils.</span></span><span class="sig-name descname"><span class="pre">remove_pua_from_str</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">string</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/searx/utils.html#remove_pua_from_str"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.utils.remove_pua_from_str" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Removes unicode’s “PRIVATE USE CHARACTER”s (<a class="reference external" href="https://en.wikipedia.org/wiki/Private_Use_Areas">PUA</a>) from a string.</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">→</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">→</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.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_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.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=<searx.utils._NotSetClass</span> <span class="pre">object></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.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, Dailymotion, and Bilibili.</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">→</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.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.parse_duration_string">
|
||||
<span class="sig-prename descclassname"><span class="pre">searx.utils.</span></span><span class="sig-name descname"><span class="pre">parse_duration_string</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">duration_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">→</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/datetime.html#datetime.timedelta" title="(in Python v3.13)"><span class="pre">timedelta</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#parse_duration_string"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.utils.parse_duration_string" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Parse a time string in format MM:SS or HH:MM:SS and convert it to a <cite>timedelta</cite> object.</p>
|
||||
<p>Returns None if the provided string doesn’t match any of the formats.</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.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.SEARCH_LANGUAGE_CODES"><code class="docutils literal notranslate"><span class="pre">SEARCH_LANGUAGE_CODES</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.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.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.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.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.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.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.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.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.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.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.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.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.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.remove_pua_from_str"><code class="docutils literal notranslate"><span class="pre">remove_pua_from_str()</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.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_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.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.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.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.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.parse_duration_string"><code class="docutils literal notranslate"><span class="pre">parse_duration_string()</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">
|
||||
© Copyright SearXNG team.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user