diff --git a/DrissionPage/driver_element.py b/DrissionPage/driver_element.py index 03934f5..152fb7d 100644 --- a/DrissionPage/driver_element.py +++ b/DrissionPage/driver_element.py @@ -61,9 +61,11 @@ class DriverElement(DrissionElement): """返回元素内所有文本""" return unescape(self.attr('innerText')).replace('\xa0', ' ') - @property - def texts(self) -> List[str]: + def texts(self, text_node_only: bool = False) -> List[str]: """返回元素内文本节点列表""" + s = '' if text_node_only else '''else if(childs[i].nodeType === Node.ELEMENT_NODE){ + texts.push(childs[i].innerText) + }''' js = ''' function e(el) { if (!(el instanceof Element)) return; @@ -73,7 +75,7 @@ class DriverElement(DrissionElement): for(var i = 0; i List[str]: + def texts(self, text_node_only: bool = False) -> List[str]: # TODO: 待补充 return []