mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
修复异域iframe可能出现的500错误
This commit is contained in:
parent
b03e919989
commit
8daf63b469
@ -48,7 +48,16 @@ class ChromiumFrame(ChromiumBase):
|
|||||||
self._timeouts = self.page.timeouts
|
self._timeouts = self.page.timeouts
|
||||||
self._page_load_strategy = self.page.page_load_strategy
|
self._page_load_strategy = self.page.page_load_strategy
|
||||||
|
|
||||||
|
def _init_page(self, tab_id=None):
|
||||||
|
"""避免出现服务器500错误
|
||||||
|
:param tab_id: 要跳转到的标签页id
|
||||||
|
:return: None
|
||||||
|
"""
|
||||||
|
self._control_session.get(f'http://{self.address}/json')
|
||||||
|
super()._init_page(tab_id)
|
||||||
|
|
||||||
def _reload(self):
|
def _reload(self):
|
||||||
|
"""重新获取document"""
|
||||||
self._frame_ele = ChromiumElement(self.page, backend_id=self._backend_id)
|
self._frame_ele = ChromiumElement(self.page, backend_id=self._backend_id)
|
||||||
node = self.page.run_cdp('DOM.describeNode', nodeId=self._frame_ele.node_id, not_change=True)['node']
|
node = self.page.run_cdp('DOM.describeNode', nodeId=self._frame_ele.node_id, not_change=True)['node']
|
||||||
|
|
||||||
@ -64,6 +73,7 @@ class ChromiumFrame(ChromiumBase):
|
|||||||
self.doc_ele = ChromiumElement(self, obj_id=obj_id)
|
self.doc_ele = ChromiumElement(self, obj_id=obj_id)
|
||||||
|
|
||||||
def _check_ok(self):
|
def _check_ok(self):
|
||||||
|
""""""
|
||||||
if self._tab_obj._stopped.is_set():
|
if self._tab_obj._stopped.is_set():
|
||||||
self._reload()
|
self._reload()
|
||||||
|
|
||||||
@ -71,7 +81,7 @@ class ChromiumFrame(ChromiumBase):
|
|||||||
self._tab_obj.DOM.describeNode(nodeId=self.node_id)
|
self._tab_obj.DOM.describeNode(nodeId=self.node_id)
|
||||||
except Exception:
|
except Exception:
|
||||||
self._reload()
|
self._reload()
|
||||||
sleep(2)
|
# sleep(2)
|
||||||
|
|
||||||
def _get_new_document(self):
|
def _get_new_document(self):
|
||||||
"""刷新cdp使用的document数据"""
|
"""刷新cdp使用的document数据"""
|
||||||
|
@ -30,6 +30,8 @@ class ChromiumFrame(ChromiumBase):
|
|||||||
|
|
||||||
def _set_options(self) -> None: ...
|
def _set_options(self) -> None: ...
|
||||||
|
|
||||||
|
def _init_page(self, tab_id: str = None) -> None: ...
|
||||||
|
|
||||||
def _reload(self) -> None: ...
|
def _reload(self) -> None: ...
|
||||||
|
|
||||||
def _check_ok(self) -> None: ...
|
def _check_ok(self) -> None: ...
|
||||||
|
Loading…
x
Reference in New Issue
Block a user