mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
3.0.15继续修复不稳定页面的加载问题
This commit is contained in:
parent
d3a06e2bbd
commit
94b6c2f339
@ -72,9 +72,11 @@ class ChromiumBase(BasePage):
|
|||||||
self._tab_obj.DOM.enable()
|
self._tab_obj.DOM.enable()
|
||||||
self._tab_obj.Page.enable()
|
self._tab_obj.Page.enable()
|
||||||
|
|
||||||
|
self._tab_obj.Page.frameStoppedLoading = self._onFrameStoppedLoading
|
||||||
|
self._tab_obj.Page.frameStartedLoading = self._onFrameStartedLoading
|
||||||
self._tab_obj.DOM.documentUpdated = self._onDocumentUpdated
|
self._tab_obj.DOM.documentUpdated = self._onDocumentUpdated
|
||||||
self._tab_obj.Page.loadEventFired = self._onLoadEventFired
|
self._tab_obj.Page.loadEventFired = self._onLoadEventFired
|
||||||
# self._tab_obj.Page.frameNavigated = self._onFrameNavigated
|
self._tab_obj.Page.frameNavigated = self._onFrameNavigated
|
||||||
|
|
||||||
def _get_document(self) -> None:
|
def _get_document(self) -> None:
|
||||||
"""刷新cdp使用的document数据"""
|
"""刷新cdp使用的document数据"""
|
||||||
@ -113,21 +115,43 @@ class ChromiumBase(BasePage):
|
|||||||
self.stop_loading()
|
self.stop_loading()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def _onFrameStartedLoading(self, **kwargs):
|
||||||
|
"""页面跳转时触发"""
|
||||||
|
# print('FrameStartedLoading')
|
||||||
|
if kwargs['frameId'] == self.tab_id:
|
||||||
|
self._is_loading = True
|
||||||
|
if self._debug:
|
||||||
|
print('FrameStartedLoading')
|
||||||
|
|
||||||
|
def _onFrameStoppedLoading(self, **kwargs):
|
||||||
|
"""页面跳转时触发"""
|
||||||
|
# print('FrameStoppedLoading')
|
||||||
|
if kwargs['frameId'] == self.tab_id and self._first_run is False and self._is_loading:
|
||||||
|
if self._debug:
|
||||||
|
print('FrameStoppedLoading')
|
||||||
|
self._get_document()
|
||||||
|
|
||||||
def _onLoadEventFired(self, **kwargs):
|
def _onLoadEventFired(self, **kwargs):
|
||||||
"""在页面刷新、变化后重新读取页面内容"""
|
"""在页面刷新、变化后重新读取页面内容"""
|
||||||
if self._first_run is False and self._is_loading:
|
|
||||||
if self._debug:
|
if self._debug:
|
||||||
print('loadEventFired')
|
print('loadEventFired')
|
||||||
self._get_document()
|
# if self._first_run is False and self._is_loading:
|
||||||
|
# if self._debug:
|
||||||
|
# print('loadEventFired')
|
||||||
|
# self._get_document()
|
||||||
|
|
||||||
def _onDocumentUpdated(self, **kwargs):
|
def _onDocumentUpdated(self, **kwargs):
|
||||||
"""页面跳转时触发"""
|
"""页面跳转时触发"""
|
||||||
self._is_loading = True
|
|
||||||
if self._debug:
|
if self._debug:
|
||||||
print('docUpdated')
|
print('docUpdated')
|
||||||
|
# self._is_loading = True
|
||||||
|
# if self._debug:
|
||||||
|
# print('docUpdated')
|
||||||
|
|
||||||
# def _onFrameNavigated(self, **kwargs):
|
def _onFrameNavigated(self, **kwargs):
|
||||||
# """页面跳转时触发"""
|
"""页面跳转时触发"""
|
||||||
|
if self._debug:
|
||||||
|
print('nav')
|
||||||
# if not kwargs['frame'].get('parentId', None):
|
# if not kwargs['frame'].get('parentId', None):
|
||||||
# self._is_loading = True
|
# self._is_loading = True
|
||||||
# if self._debug:
|
# if self._debug:
|
||||||
@ -588,7 +612,6 @@ class ChromiumBase(BasePage):
|
|||||||
if err:
|
if err:
|
||||||
if show_errmsg:
|
if show_errmsg:
|
||||||
raise err if err is not None else ConnectionError('连接异常。')
|
raise err if err is not None else ConnectionError('连接异常。')
|
||||||
self._get_document()
|
|
||||||
|
|
||||||
return False if err else True
|
return False if err else True
|
||||||
|
|
||||||
|
2
setup.py
2
setup.py
@ -6,7 +6,7 @@ with open("README.md", "r", encoding='utf-8') as fh:
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="DrissionPage",
|
name="DrissionPage",
|
||||||
version="3.0.14",
|
version="3.0.15",
|
||||||
author="g1879",
|
author="g1879",
|
||||||
author_email="g1879@qq.com",
|
author_email="g1879@qq.com",
|
||||||
description="A module that integrates selenium and requests session, encapsulates common page operations.",
|
description="A module that integrates selenium and requests session, encapsulates common page operations.",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user