MCPcopy
hub / github.com/searx/searx / eval_xpath_list

Function eval_xpath_list

searx/utils.py:565–586  ·  view source on GitHub ↗

Same as eval_xpath, check if the result is a list Args: * element (ElementBase): [description] * xpath_spec (str|lxml.etree.XPath): XPath as a str or lxml.etree.XPath * min_len (int, optional): [description]. Defaults to None. Raises: * TypeError: Raise when

(element, xpath_spec, min_len=None)

Source from the content-addressed store, hash-verified

563
564
565def eval_xpath_list(element, xpath_spec, min_len=None):
566 """Same as eval_xpath, check if the result is a list
567
568 Args:
569 * element (ElementBase): [description]
570 * xpath_spec (str|lxml.etree.XPath): XPath as a str or lxml.etree.XPath
571 * min_len (int, optional): [description]. Defaults to None.
572
573 Raises:
574 * TypeError: Raise when xpath_spec is neither a str nor a lxml.etree.XPath
575 * SearxXPathSyntaxException: Raise when there is a syntax error in the XPath
576 * SearxEngineXPathException: raise if the result is not a list
577
578 Returns:
579 * result (bool, float, list, str): Results.
580 """
581 result = eval_xpath(element, xpath_spec)
582 if not isinstance(result, list):
583 raise SearxEngineXPathException(xpath_spec, 'the result is not a list')
584 if min_len is not None and min_len > len(result):
585 raise SearxEngineXPathException(xpath_spec, 'len(xpath_str) < ' + str(min_len))
586 return result
587
588
589def eval_xpath_getindex(elements, xpath_spec, index, default=NOTSET):

Callers 15

responseFunction · 0.90
responseFunction · 0.90
scrap_out_thumbsFunction · 0.90
responseFunction · 0.90
responseFunction · 0.90
responseFunction · 0.90
responseFunction · 0.90
requestFunction · 0.90
responseFunction · 0.90
responseFunction · 0.90

Calls 2

eval_xpathFunction · 0.85

Tested by

no test coverage detected