fix(lxml): Adjust HTML element checks to prevent FutureWarning

This commit is contained in:
InfinityPacer
2024-08-31 02:14:52 +08:00
parent 9ab852c1ad
commit 93801e857e
13 changed files with 35 additions and 23 deletions

View File

@@ -795,3 +795,13 @@ class StringUtils:
:return: 如果输入值不是 None返回去除空白字符后的字符串否则返回 None
"""
return value.strip() if value is not None else None
@staticmethod
def is_valid_html_element(elem) -> bool:
"""
检查elem是否为有效的HTML元素。元素必须为非None并且具有非零长度。
:param elem: 要检查的HTML元素
:return: 如果elem有效非None且长度大于0返回True否则返回False
"""
return elem is not None and len(elem) > 0