ChromiumFrame补充style();DownloadKit指定2.0.7或以上

This commit is contained in:
g1879 2024-12-01 22:37:38 +08:00
parent 2db39d3176
commit 0d9951f516
5 changed files with 18 additions and 4 deletions

View File

@ -33,7 +33,7 @@ from .._units.scroller import PageScroller
from .._units.setter import ChromiumBaseSetter
from .._units.states import PageStates
from .._units.waiter import BaseWaiter
from ..errors import ContextLostError, CDPError, PageDisconnectedError, ElementLostError
from ..errors import ContextLostError, CDPError, PageDisconnectedError, ElementLostError, JavaScriptError
__ERROR__ = 'error'
@ -600,7 +600,10 @@ class ChromiumBase(BasePage):
else:
raise TypeError('html_or_info参数必须是html文本或tupletuple格式为(tag, {name: value})。')
ele = self._run_js(js, *args)
try:
ele = self._run_js(js, *args)
except JavaScriptError:
raise RuntimeError('此网页DOM不允许修改。')
return ele
def get_frame(self, loc_ind_ele, timeout=None):

View File

@ -333,6 +333,9 @@ class ChromiumFrame(ChromiumBase):
def remove_attr(self, name):
self.frame_ele.remove_attr(name)
def style(self, style, pseudo_ele=''):
return self.frame_ele.style(style=style, pseudo_ele=pseudo_ele)
def run_js(self, script, *args, as_expr=False, timeout=None):
return self._run_js(script, *args, as_expr=as_expr, timeout=timeout)

View File

@ -240,6 +240,14 @@ class ChromiumFrame(ChromiumBase):
"""
...
def style(self, style: str, pseudo_ele: str = '') -> str:
"""返回frame元素样式属性值可获取伪元素属性值
:param style: 样式属性名称
:param pseudo_ele: 伪元素名称如有
:return: 样式属性的值
"""
...
def run_js(self,
script: str,
*args,

View File

@ -1,7 +1,7 @@
requests
lxml
cssselect
DownloadKit>=2.0.5
DownloadKit>=2.0.7
websocket-client
click
tldextract>=3.4.4

View File

@ -23,7 +23,7 @@ setup(
'lxml',
'requests',
'cssselect',
'DownloadKit>=2.0.5',
'DownloadKit>=2.0.7',
'websocket-client',
'click',
'tldextract>=3.4.4',