mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
Page对象初始化删除timeout提示,以后废弃
This commit is contained in:
parent
6a96b227af
commit
e54171710b
@ -19,6 +19,7 @@ class ChromiumPage(ChromiumBase):
|
|||||||
_PAGES = {}
|
_PAGES = {}
|
||||||
|
|
||||||
def __new__(cls, addr_or_opts=None, tab_id=None, timeout=None):
|
def __new__(cls, addr_or_opts=None, tab_id=None, timeout=None):
|
||||||
|
# 即将废弃timeout
|
||||||
browser = Chromium(addr_or_opts=addr_or_opts)
|
browser = Chromium(addr_or_opts=addr_or_opts)
|
||||||
if browser.id in cls._PAGES:
|
if browser.id in cls._PAGES:
|
||||||
r = cls._PAGES[browser.id]
|
r = cls._PAGES[browser.id]
|
||||||
@ -32,6 +33,7 @@ class ChromiumPage(ChromiumBase):
|
|||||||
return r
|
return r
|
||||||
|
|
||||||
def __init__(self, addr_or_opts=None, tab_id=None, timeout=None):
|
def __init__(self, addr_or_opts=None, tab_id=None, timeout=None):
|
||||||
|
# 即将废弃timeout
|
||||||
if hasattr(self, '_created'):
|
if hasattr(self, '_created'):
|
||||||
return
|
return
|
||||||
self._created = True
|
self._created = True
|
||||||
@ -39,7 +41,7 @@ class ChromiumPage(ChromiumBase):
|
|||||||
self.tab = self
|
self.tab = self
|
||||||
super().__init__(self.browser, tab_id)
|
super().__init__(self.browser, tab_id)
|
||||||
self._type = 'ChromiumPage'
|
self._type = 'ChromiumPage'
|
||||||
self.set.timeouts(base=timeout)
|
self.set.timeouts(base=timeout) # 即将废弃
|
||||||
self._tab = self
|
self._tab = self
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
@ -27,23 +27,19 @@ class ChromiumPage(ChromiumBase):
|
|||||||
|
|
||||||
def __new__(cls,
|
def __new__(cls,
|
||||||
addr_or_opts: Union[str, int, ChromiumOptions] = None,
|
addr_or_opts: Union[str, int, ChromiumOptions] = None,
|
||||||
tab_id: str = None,
|
tab_id: str = None):
|
||||||
timeout: float = None):
|
|
||||||
"""
|
"""
|
||||||
:param addr_or_opts: 浏览器地址:端口、ChromiumOptions对象或端口数字(int)
|
:param addr_or_opts: 浏览器地址:端口、ChromiumOptions对象或端口数字(int)
|
||||||
:param tab_id: 要控制的标签页id,不指定默认为激活的
|
:param tab_id: 要控制的标签页id,不指定默认为激活的
|
||||||
:param timeout: 超时时间(秒)
|
|
||||||
"""
|
"""
|
||||||
...
|
...
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
addr_or_opts: Union[str, int, ChromiumOptions] = None,
|
addr_or_opts: Union[str, int, ChromiumOptions] = None,
|
||||||
tab_id: str = None,
|
tab_id: str = None):
|
||||||
timeout: float = None):
|
|
||||||
"""
|
"""
|
||||||
:param addr_or_opts: 浏览器地址:端口、ChromiumOptions对象或端口数字(int)
|
:param addr_or_opts: 浏览器地址:端口、ChromiumOptions对象或端口数字(int)
|
||||||
:param tab_id: 要控制的标签页id,不指定默认为激活的
|
:param tab_id: 要控制的标签页id,不指定默认为激活的
|
||||||
:param timeout: 超时时间(秒)
|
|
||||||
"""
|
"""
|
||||||
...
|
...
|
||||||
|
|
||||||
|
@ -22,16 +22,17 @@ from .._units.setter import SessionPageSetter
|
|||||||
|
|
||||||
|
|
||||||
class SessionPage(BasePage):
|
class SessionPage(BasePage):
|
||||||
def __init__(self, session_or_options=None):
|
def __init__(self, session_or_options=None, timeout=None):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._response = None
|
self._response = None
|
||||||
self._set = None
|
self._set = None
|
||||||
self._encoding = None
|
self._encoding = None
|
||||||
self._type = 'SessionPage'
|
self._type = 'SessionPage'
|
||||||
self._page = self
|
self._page = self
|
||||||
self._timeout = 10
|
|
||||||
self._set_session_options(session_or_options)
|
self._set_session_options(session_or_options)
|
||||||
self._s_set_runtime_settings()
|
self._s_set_runtime_settings()
|
||||||
|
if timeout is not None: # 即将废弃
|
||||||
|
self._timeout = timeout
|
||||||
if not self._session:
|
if not self._session:
|
||||||
self._create_session()
|
self._create_session()
|
||||||
|
|
||||||
|
@ -32,8 +32,7 @@ class SessionPage(BasePage):
|
|||||||
_encoding: Optional[str] = ...
|
_encoding: Optional[str] = ...
|
||||||
_page: SessionPage = ...
|
_page: SessionPage = ...
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self, session_or_options: Union[Session, SessionOptions] = None):
|
||||||
session_or_options: Union[Session, SessionOptions] = None):
|
|
||||||
"""
|
"""
|
||||||
:param session_or_options: Session对象或SessionOptions对象
|
:param session_or_options: Session对象或SessionOptions对象
|
||||||
"""
|
"""
|
||||||
@ -260,7 +259,7 @@ class SessionPage(BasePage):
|
|||||||
"""返回cookies
|
"""返回cookies
|
||||||
:param all_domains: 是否返回所有域的cookies
|
:param all_domains: 是否返回所有域的cookies
|
||||||
:param all_info: 是否返回所有信息,False则只返回name、value、domain
|
:param all_info: 是否返回所有信息,False则只返回name、value、domain
|
||||||
:return: cookies信息
|
:return: cookies组成的列表
|
||||||
"""
|
"""
|
||||||
...
|
...
|
||||||
|
|
||||||
|
@ -17,15 +17,11 @@ from .._units.setter import WebPageSetter
|
|||||||
|
|
||||||
class WebPage(SessionPage, ChromiumPage, BasePage):
|
class WebPage(SessionPage, ChromiumPage, BasePage):
|
||||||
def __new__(cls, mode='d', timeout=None, chromium_options=None, session_or_options=None):
|
def __new__(cls, mode='d', timeout=None, chromium_options=None, session_or_options=None):
|
||||||
"""初始化函数
|
# 即将废弃timeout
|
||||||
:param mode: 'd' 或 's',即driver模式和session模式
|
|
||||||
:param timeout: 超时时间(秒),d模式时为寻找元素时间,s模式时为连接时间,默认10秒
|
|
||||||
:param chromium_options: Driver对象,只使用s模式时应传入False
|
|
||||||
:param session_or_options: Session对象或SessionOptions对象,只使用d模式时应传入False
|
|
||||||
"""
|
|
||||||
return super().__new__(cls, chromium_options)
|
return super().__new__(cls, chromium_options)
|
||||||
|
|
||||||
def __init__(self, mode='d', timeout=None, chromium_options=None, session_or_options=None):
|
def __init__(self, mode='d', timeout=None, chromium_options=None, session_or_options=None):
|
||||||
|
# 即将废弃timeout
|
||||||
if hasattr(self, '_created'):
|
if hasattr(self, '_created'):
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -40,7 +36,7 @@ class WebPage(SessionPage, ChromiumPage, BasePage):
|
|||||||
if not chromium_options:
|
if not chromium_options:
|
||||||
chromium_options = ChromiumOptions(read_file=chromium_options)
|
chromium_options = ChromiumOptions(read_file=chromium_options)
|
||||||
chromium_options.set_timeouts(base=self._timeout).set_paths(download_path=self.download_path)
|
chromium_options.set_timeouts(base=self._timeout).set_paths(download_path=self.download_path)
|
||||||
super(SessionPage, self).__init__(addr_or_opts=chromium_options, timeout=timeout)
|
super(SessionPage, self).__init__(addr_or_opts=chromium_options, timeout=timeout) # 即将废弃timeout
|
||||||
self._type = 'WebPage'
|
self._type = 'WebPage'
|
||||||
self.change_mode(mode, go=False, copy_cookies=False)
|
self.change_mode(mode, go=False, copy_cookies=False)
|
||||||
|
|
||||||
|
@ -35,14 +35,12 @@ class WebPage(SessionPage, ChromiumPage, BasePage):
|
|||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
mode: str = 'd',
|
mode: str = 'd',
|
||||||
timeout: float = None,
|
|
||||||
chromium_options: Union[ChromiumOptions, bool] = None,
|
chromium_options: Union[ChromiumOptions, bool] = None,
|
||||||
session_or_options: Union[Session, SessionOptions, bool] = None) -> None:
|
session_or_options: Union[Session, SessionOptions, bool] = None) -> None:
|
||||||
"""初始化函数
|
"""初始化函数
|
||||||
:param mode: 'd' 或 's',即driver模式和session模式
|
:param mode: 'd' 或 's',即driver模式和session模式
|
||||||
:param timeout: 超时时间(秒),d模式时为寻找元素时间,s模式时为连接时间,默认10秒
|
:param chromium_options: ChromiumOptions对象,传入None时从默认ini文件读取,传入False时不读取ini文件,使用默认配置
|
||||||
:param chromium_options: ChromiumOptions对象,只使用s模式时应传入False
|
:param session_or_options: Session对象或SessionOptions对象,传入None时从默认ini文件读取,传入False时不读取ini文件,使用默认配置
|
||||||
:param session_or_options: Session对象或SessionOptions对象,只使用d模式时应传入False
|
|
||||||
"""
|
"""
|
||||||
...
|
...
|
||||||
|
|
||||||
|
@ -151,11 +151,11 @@ class BaseWaiter(OriginWaiter):
|
|||||||
"""等待自动填写上传文件路径"""
|
"""等待自动填写上传文件路径"""
|
||||||
...
|
...
|
||||||
|
|
||||||
def download_begin(self, timeout: float = None, cancel_it: bool = False) -> Union[DownloadMission, bool]:
|
def download_begin(self, timeout: float = None, cancel_it: bool = False) -> Union[DownloadMission, bool, dict]:
|
||||||
"""等待浏览器下载开始,可将其拦截
|
"""等待浏览器下载开始,可将其拦截
|
||||||
:param timeout: 超时时间(秒),None使用页面对象超时时间
|
:param timeout: 超时时间(秒),None使用页面对象超时时间
|
||||||
:param cancel_it: 是否取消该任务
|
:param cancel_it: 是否取消该任务
|
||||||
:return: 成功返回任务对象,失败返回False
|
:return: 成功返回任务对象(cancel_it为True时返回dict格式的下载信息),失败返回False
|
||||||
"""
|
"""
|
||||||
...
|
...
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user