mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
元素对象添加row_text属性
This commit is contained in:
parent
94ab5975a9
commit
78554f8145
@ -4,6 +4,7 @@
|
|||||||
@Contact : g1879@qq.com
|
@Contact : g1879@qq.com
|
||||||
@File : driver_element.py
|
@File : driver_element.py
|
||||||
"""
|
"""
|
||||||
|
import re
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Union, List, Any, Tuple
|
from typing import Union, List, Any, Tuple
|
||||||
|
|
||||||
@ -78,13 +79,17 @@ class DriverElement(DrissionElement):
|
|||||||
@property
|
@property
|
||||||
def text(self) -> str:
|
def text(self) -> str:
|
||||||
"""返回元素内所有文本"""
|
"""返回元素内所有文本"""
|
||||||
return format_html(self.inner_ele.get_attribute('innerText'), False)
|
# return format_html(self.inner_ele.get_attribute('innerText'), False)
|
||||||
# return self.inner_ele.get_attribute('innerText')
|
re_str = self.inner_ele.get_attribute('innerText')
|
||||||
# re_str = self.inner_ele.get_attribute('innerText')
|
re_str = re.sub(r'\n{2,}', '\n', re_str)
|
||||||
# re_str = re.sub(r'\n{2,}', '\n', re_str)
|
re_str = re.sub(r' {2,}', ' ', re_str)
|
||||||
# re_str = re.sub(r' {2,}', ' ', re_str)
|
|
||||||
#
|
return format_html(re_str.strip('\n '), False)
|
||||||
# return format_html(re_str.strip('\n '))
|
|
||||||
|
@property
|
||||||
|
def row_text(self) -> str:
|
||||||
|
"""返回未格式化处理的元素内文本"""
|
||||||
|
return self.inner_ele.get_attribute('innerText')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def link(self) -> str:
|
def link(self) -> str:
|
||||||
|
@ -82,12 +82,10 @@ class SessionElement(DrissionElement):
|
|||||||
re_str = re.sub(r' {2,}', ' ', re_str)
|
re_str = re.sub(r' {2,}', ' ', re_str)
|
||||||
return format_html(re_str, False)
|
return format_html(re_str, False)
|
||||||
|
|
||||||
# re_str = str(self._inner_ele.text_content())
|
@property
|
||||||
# # re_str = re.sub(r'<br */?>', '\n', re_str)
|
def row_text(self) -> str:
|
||||||
# re_str = re.sub(r'\n{2,}', '\n', re_str)
|
"""返回未格式化处理的元素内文本"""
|
||||||
# re_str = re.sub(r' {2,}', ' ', re_str)
|
return str(self._inner_ele.text_content())
|
||||||
# return format_html(re_str.strip('\n '))
|
|
||||||
# # return format_html(re_str)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def tag(self) -> str:
|
def tag(self) -> str:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user