.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._HTMLTextExtractorException
 
class  searx.utils._HTMLTextExtractor
 

Namespaces

namespace  searx
 
namespace  searx.utils
 

Functions

str searx.utils.searx_useragent ()
 
str searx.utils.gen_useragent (Optional[str] os_string=None)
 
str searx.utils.html_to_text (str html_str)
 
str searx.utils.markdown_to_text (str markdown_str)
 
Optional[str] searx.utils.extract_text (xpath_results, bool allow_none=False)
 
str searx.utils.normalize_url (str url, str base_url)
 
str searx.utils.extract_url (xpath_results, base_url)
 
Dict searx.utils.dict_subset (MutableMapping dictionary, Set[str] properties)
 
 searx.utils.humanize_bytes (size, precision=2)
 
 searx.utils.humanize_number (size, 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 (Union[List[str], str] num)
 
Optional[Tuple[bool, str, str]] searx.utils.is_valid_lang (lang)
 
types.ModuleType searx.utils.load_module (str filename, str module_dir)
 
str searx.utils.to_string (Any obj)
 
str searx.utils.ecma_unescape (str string)
 
Callable[[str], str] searx.utils.get_string_replaces_function (Dict[str, str] replaces)
 
Dict searx.utils.get_engine_from_settings (str name)
 
XPath searx.utils.get_xpath (XPathSpecType xpath_spec)
 
 searx.utils.eval_xpath (ElementBase element, XPathSpecType xpath_spec)
 
 searx.utils.eval_xpath_list (ElementBase element, XPathSpecType xpath_spec, Optional[int] min_len=None)
 
 searx.utils.eval_xpath_getindex (ElementBase elements, XPathSpecType xpath_spec, int index, default=_NOTSET)
 
"fasttext.FastText._FastText" searx.utils._get_fasttext_model ()
 
 searx.utils.get_embeded_stream_url (url)
 
Optional[str] searx.utils.detect_language (str text, float threshold=0.3, bool only_search_languages=False)
 
 searx.utils.js_variable_to_python (js_variable)
 

Variables

 searx.utils.logger = logger.getChild('utils')
 
 searx.utils.XPathSpecType = Union[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 = {}
 
Optional 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()