.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
utils.py File Reference

Go to the source code of this file.

Classes

class  searx.utils._NotSetClass
class  searx.utils.HTMLTextExtractor

Namespaces

namespace  searx
namespace  searx.utils

Functions

str searx.utils.searxng_useragent ()
str searx.utils.gen_useragent (str|None os_string=None)
str searx.utils.html_to_text (str html_str)
str searx.utils.markdown_to_text (str markdown_str)
str|None searx.utils.extract_text (list[ElementBase]|ElementBase|str|Number|bool|None xpath_results, bool allow_none=False)
str searx.utils.normalize_url (str url, str base_url)
str searx.utils.extract_url (list[ElementBase]|ElementBase|str|Number|bool|None xpath_results, str base_url)
MutableMapping[str, t.Any] searx.utils.dict_subset (MutableMapping[t.Any, t.Any] dictionary, set[str] properties)
 searx.utils.humanize_bytes (int|float size, int precision=2)
 searx.utils.humanize_number (int|float size, int precision=0)
int searx.utils.convert_str_to_int (str number_str)
 searx.utils.extr (str txt, str begin, str end, str default="")
int searx.utils.int_or_zero (list[str]|str num)
tuple[bool, str, str]|None searx.utils.is_valid_lang (str lang)
types.ModuleType searx.utils.load_module (str filename, str module_dir)
str searx.utils.to_string (t.Any obj)
str searx.utils.ecma_unescape (str string)
 searx.utils.remove_pua_from_str (str string)
Callable[[str], str] searx.utils.get_string_replaces_function (dict[str, str] replaces)
dict[str, dict[str, str]] searx.utils.get_engine_from_settings (str name)
XPath searx.utils.get_xpath (XPathSpecType xpath_spec)
t.Any searx.utils.eval_xpath (ElementBase element, XPathSpecType xpath_spec)
list[t.Any] searx.utils.eval_xpath_list (ElementBase element, XPathSpecType xpath_spec, int|None min_len=None)
t.Any searx.utils.eval_xpath_getindex (ElementBase element, XPathSpecType xpath_spec, int index, t.Any default=_NOTSET)
"fasttext.FastText._FastText" searx.utils._get_fasttext_model ()
 searx.utils.get_embeded_stream_url (str url)
str|None searx.utils.detect_language (str text, float threshold=0.3, bool only_search_languages=False)
str searx.utils.js_variable_to_python (str js_variable)
timedelta|None searx.utils.parse_duration_string (str duration_str)

Variables

 searx.utils.logger = logger.getChild('utils')
searx.utils.XPathSpecType = str | XPath
tuple searx.utils._BLOCKED_TAGS = ('script', 'style')
 searx.utils._ECMA_UNESCAPE4_RE = re.compile(r'%u([0-9a-fA-F]{4})', re.UNICODE)
 searx.utils._ECMA_UNESCAPE2_RE = re.compile(r'%([0-9a-fA-F]{2})', re.UNICODE)
 searx.utils._JS_QUOTE_KEYS_RE = re.compile(r'([\{\s,])(\w+)(:)')
 searx.utils._JS_VOID_RE = re.compile(r'void\s+[0-9]+|void\s*\‍([0-9]+\‍)')
 searx.utils._JS_DECIMAL_RE = re.compile(r":\s*\.")
dict searx.utils._XPATH_CACHE = {}
dict searx.utils._LANG_TO_LC_CACHE = {}
str searx.utils._FASTTEXT_MODEL = None
 searx.utils.SEARCH_LANGUAGE_CODES = frozenset([searxng_locale[0].split('-')[0] for searxng_locale in sxng_locales])
 searx.utils._NOTSET = _NotSetClass()