mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
微调_get_document()
This commit is contained in:
parent
dcbf970075
commit
e56995dcf0
@ -151,29 +151,31 @@ class ChromiumBase(BasePage):
|
|||||||
"""
|
"""
|
||||||
if self._is_reading:
|
if self._is_reading:
|
||||||
return
|
return
|
||||||
timeout = timeout if timeout >= .5 else .5
|
|
||||||
self._is_reading = True
|
self._is_reading = True
|
||||||
|
timeout = timeout if timeout >= .5 else .5
|
||||||
end_time = perf_counter() + timeout
|
end_time = perf_counter() + timeout
|
||||||
while perf_counter() < end_time:
|
while perf_counter() < end_time:
|
||||||
try:
|
try:
|
||||||
b_id = self.run_cdp('DOM.getDocument', _timeout=timeout)['root']['backendNodeId']
|
b_id = self.run_cdp('DOM.getDocument', _timeout=timeout)['root']['backendNodeId']
|
||||||
timeout = end_time - perf_counter()
|
timeout = end_time - perf_counter()
|
||||||
timeout = .5 if timeout < 0 else timeout
|
timeout = .5 if timeout <= 0 else timeout
|
||||||
self._root_id = self.run_cdp('DOM.resolveNode',
|
self._root_id = self.run_cdp('DOM.resolveNode', backendNodeId=b_id,
|
||||||
backendNodeId=b_id, _timeout=timeout)['object']['objectId']
|
_timeout=timeout)['object']['objectId']
|
||||||
r = self.run_cdp('Page.getFrameTree')
|
|
||||||
for i in findall(r"'id': '(.*?)'", str(r)):
|
|
||||||
self.browser._frames[i] = self.tab_id
|
|
||||||
result = True
|
result = True
|
||||||
break
|
break
|
||||||
|
|
||||||
except:
|
except:
|
||||||
timeout = end_time - perf_counter()
|
timeout = end_time - perf_counter()
|
||||||
timeout = .5 if timeout < 0 else timeout
|
timeout = .5 if timeout <= 0 else timeout
|
||||||
|
|
||||||
else:
|
else:
|
||||||
result = False
|
result = False
|
||||||
|
|
||||||
|
if result:
|
||||||
|
r = self.run_cdp('Page.getFrameTree')
|
||||||
|
for i in findall(r"'id': '(.*?)'", str(r)):
|
||||||
|
self.browser._frames[i] = self.tab_id
|
||||||
|
|
||||||
self._is_loading = False
|
self._is_loading = False
|
||||||
self._is_reading = False
|
self._is_reading = False
|
||||||
return result
|
return result
|
||||||
|
Loading…
x
Reference in New Issue
Block a user