4.1.0.0b21 MixPage改回WebPage

This commit is contained in:
g1879 2024-08-30 20:09:47 +08:00
parent 70bff8555c
commit bd88d15d7e
18 changed files with 74 additions and 77 deletions

View File

@ -9,8 +9,7 @@ from ._base.chromium import Chromium
from ._configs.chromium_options import ChromiumOptions from ._configs.chromium_options import ChromiumOptions
from ._configs.session_options import SessionOptions from ._configs.session_options import SessionOptions
from ._pages.chromium_page import ChromiumPage from ._pages.chromium_page import ChromiumPage
from ._pages.mix_page import MixPage
from ._pages.mix_page import MixPage as WebPage
from ._pages.session_page import SessionPage from ._pages.session_page import SessionPage
from ._pages.web_page import WebPage
__version__ = '4.1.0.0b21' __version__ = '4.1.0.0b21'

View File

@ -9,9 +9,8 @@ from ._base.chromium import Chromium
from ._configs.chromium_options import ChromiumOptions from ._configs.chromium_options import ChromiumOptions
from ._configs.session_options import SessionOptions from ._configs.session_options import SessionOptions
from ._pages.chromium_page import ChromiumPage from ._pages.chromium_page import ChromiumPage
from ._pages.mix_page import MixPage
from ._pages.mix_page import MixPage as WebPage
from ._pages.session_page import SessionPage from ._pages.session_page import SessionPage
from ._pages.web_page import WebPage
__all__ = ['MixPage', 'WebPage', 'ChromiumPage', 'Chromium', 'ChromiumOptions', 'SessionOptions', 'SessionPage', '__version__'] __all__ = ['WebPage', 'ChromiumPage', 'Chromium', 'ChromiumOptions', 'SessionOptions', 'SessionPage', '__version__']
__version__: str = ... __version__: str = ...

View File

@ -15,8 +15,8 @@ from .._elements.session_element import SessionElement
from .._functions.elements import SessionElementsList from .._functions.elements import SessionElementsList
from .._pages.chromium_frame import ChromiumFrame from .._pages.chromium_frame import ChromiumFrame
from .._pages.chromium_page import ChromiumPage from .._pages.chromium_page import ChromiumPage
from .._pages.mix_page import MixPage
from .._pages.session_page import SessionPage from .._pages.session_page import SessionPage
from .._pages.web_page import WebPage
class BaseParser(object): class BaseParser(object):
@ -338,7 +338,7 @@ class BasePage(BaseParser):
_DownloadKit: Optional[DownloadKit] = ... _DownloadKit: Optional[DownloadKit] = ...
_none_ele_return_value: bool = ... _none_ele_return_value: bool = ...
_none_ele_value: Any = ... _none_ele_value: Any = ...
_page: Union[ChromiumPage, SessionPage, MixPage] = ... _page: Union[ChromiumPage, SessionPage, WebPage] = ...
def __init__(self): ... def __init__(self): ...

View File

@ -225,7 +225,7 @@ class Chromium(object):
background: bool = False, background: bool = False,
new_context: bool = False) -> Union[ChromiumTab, MixTab]: new_context: bool = False) -> Union[ChromiumTab, MixTab]:
"""新建一个标签页 """新建一个标签页
:param obj: 要创建的Tab类型 :param mix: 是否创建MixTab
:param url: 新标签页跳转到的网址 :param url: 新标签页跳转到的网址
:param new_window: 是否在新窗口打开标签页 :param new_window: 是否在新窗口打开标签页
:param background: 是否不激活新标签页如new_window为True则无效 :param background: 是否不激活新标签页如new_window为True则无效

View File

@ -12,7 +12,7 @@ from typing import Union, Callable, Dict, Optional
from requests import Response from requests import Response
from websocket import WebSocket from websocket import WebSocket
from .browser import Chromium from .._base.chromium import Chromium
class Driver(object): class Driver(object):

View File

@ -27,8 +27,8 @@ from .._units.selector import SelectElement
from .._units.setter import ChromiumElementSetter from .._units.setter import ChromiumElementSetter
from .._units.states import ElementStates, ShadowRootStates from .._units.states import ElementStates, ShadowRootStates
from .._units.waiter import ElementWaiter from .._units.waiter import ElementWaiter
from ..errors import ContextLostError, ElementLostError, JavaScriptError, CDPError, NoResourceError, AlertExistsError, \ from ..errors import (ContextLostError, ElementLostError, JavaScriptError, CDPError, NoResourceError,
NoRectError AlertExistsError, NoRectError)
__FRAME_ELEMENT__ = ('iframe', 'frame') __FRAME_ELEMENT__ = ('iframe', 'frame')

View File

@ -15,7 +15,7 @@ from .._pages.chromium_base import ChromiumBase
from .._pages.chromium_frame import ChromiumFrame from .._pages.chromium_frame import ChromiumFrame
from .._pages.chromium_page import ChromiumPage from .._pages.chromium_page import ChromiumPage
from .._pages.chromium_tab import ChromiumTab from .._pages.chromium_tab import ChromiumTab
from .._pages.mix_page import MixPage from .._pages.web_page import WebPage
from .._units.clicker import Clicker from .._units.clicker import Clicker
from .._units.rect import ElementRect from .._units.rect import ElementRect
from .._units.scroller import ElementScroller from .._units.scroller import ElementScroller
@ -30,7 +30,7 @@ PIC_TYPE = Literal['jpg', 'jpeg', 'png', 'webp', True]
class ChromiumElement(DrissionElement): class ChromiumElement(DrissionElement):
_tag: Optional[str] = ... _tag: Optional[str] = ...
owner: ChromiumBase = ... owner: ChromiumBase = ...
page: Union[ChromiumPage, MixPage] = ... page: Union[ChromiumPage, WebPage] = ...
tab: Union[ChromiumPage, ChromiumTab] = ... tab: Union[ChromiumPage, ChromiumTab] = ...
_node_id: int = ... _node_id: int = ...
_obj_id: str = ... _obj_id: str = ...
@ -898,7 +898,7 @@ def find_by_css(ele: ChromiumElement,
... ...
def make_chromium_eles(page: Union[ChromiumBase, ChromiumPage, MixPage, ChromiumTab, ChromiumFrame], def make_chromium_eles(page: Union[ChromiumBase, ChromiumPage, WebPage, ChromiumTab, ChromiumFrame],
_ids: Union[tuple, list, str, int], _ids: Union[tuple, list, str, int],
index: Optional[int] = 1, index: Optional[int] = 1,
is_obj_id: bool = True, is_obj_id: bool = True,

View File

@ -10,8 +10,8 @@ from typing import Union, Tuple, Any, Optional, Literal
from .chromium_page import ChromiumPage from .chromium_page import ChromiumPage
from .chromium_tab import ChromiumTab from .chromium_tab import ChromiumTab
from .mix_page import MixPage
from .mix_tab import MixTab from .mix_tab import MixTab
from .web_page import WebPage
from .._base.base import BasePage from .._base.base import BasePage
from .._base.chromium import Chromium from .._base.chromium import Chromium
from .._base.driver import Driver from .._base.driver import Driver
@ -34,7 +34,7 @@ PIC_TYPE = Literal['jpg', 'jpeg', 'png', 'webp', True]
class ChromiumBase(BasePage): class ChromiumBase(BasePage):
_tab: Union[ChromiumTab, MixTab, ChromiumFrame, ChromiumPage, MixPage] = ... _tab: Union[ChromiumTab, MixTab, ChromiumFrame, ChromiumPage, WebPage] = ...
_browser: Chromium = ... _browser: Chromium = ...
_driver: Optional[Driver] = ... _driver: Optional[Driver] = ...
_frame_id: str = ... _frame_id: str = ...

View File

@ -11,10 +11,10 @@ from .._base.base import BasePage
from .._configs.chromium_options import ChromiumOptions from .._configs.chromium_options import ChromiumOptions
from .._functions.cookies import set_session_cookies, set_tab_cookies from .._functions.cookies import set_session_cookies, set_tab_cookies
from .._functions.settings import Settings from .._functions.settings import Settings
from .._units.setter import MixPageSetter from .._units.setter import WebPageSetter
class MixPage(SessionPage, ChromiumPage, BasePage): class WebPage(SessionPage, ChromiumPage, BasePage):
"""整合浏览器和request的页面类""" """整合浏览器和request的页面类"""
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):
@ -42,7 +42,7 @@ class MixPage(SessionPage, ChromiumPage, BasePage):
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)
self._type = 'MixPage' self._type = 'WebPage'
self.change_mode(mode, go=False, copy_cookies=False) self.change_mode(mode, go=False, copy_cookies=False)
def __call__(self, locator, index=1, timeout=None): def __call__(self, locator, index=1, timeout=None):
@ -57,7 +57,7 @@ class MixPage(SessionPage, ChromiumPage, BasePage):
@property @property
def set(self): def set(self):
if self._set is None: if self._set is None:
self._set = MixPageSetter(self) self._set = WebPageSetter(self)
return self._set return self._set
@property @property
@ -252,4 +252,4 @@ class MixPage(SessionPage, ChromiumPage, BasePage):
self._has_driver = None self._has_driver = None
def __repr__(self): def __repr__(self):
return f'<MixPage browser_id={self.browser.id} tab_id={self.tab_id}>' return f'<WebPage browser_id={self.browser.id} tab_id={self.tab_id}>'

View File

@ -20,13 +20,13 @@ from .._configs.session_options import SessionOptions
from .._elements.chromium_element import ChromiumElement from .._elements.chromium_element import ChromiumElement
from .._elements.session_element import SessionElement from .._elements.session_element import SessionElement
from .._functions.elements import SessionElementsList, ChromiumElementsList from .._functions.elements import SessionElementsList, ChromiumElementsList
from .._units.setter import MixPageSetter from .._units.setter import WebPageSetter
from .._units.waiter import MixPageWaiter from .._units.waiter import WebPageWaiter
class MixPage(SessionPage, ChromiumPage, BasePage): class WebPage(SessionPage, ChromiumPage, BasePage):
_d_mode: bool = ... _d_mode: bool = ...
_set: MixPageSetter = ... _set: WebPageSetter = ...
_has_driver: Optional[bool] = ... _has_driver: Optional[bool] = ...
_has_session: Optional[bool] = ... _has_session: Optional[bool] = ...
_session_options: Union[SessionOptions, None] = ... _session_options: Union[SessionOptions, None] = ...
@ -58,18 +58,18 @@ class MixPage(SessionPage, ChromiumPage, BasePage):
... ...
@property @property
def latest_tab(self) -> Union[MixTab, MixPage, str]: def latest_tab(self) -> Union[MixTab, WebPage, str]:
"""返回最新的标签页,最新标签页指最后创建或最后被激活的 """返回最新的标签页,最新标签页指最后创建或最后被激活的
当Settings.singleton_tab_obj==True时返回Tab对象否则返回tab id""" 当Settings.singleton_tab_obj==True时返回Tab对象否则返回tab id"""
... ...
@property @property
def set(self) -> MixPageSetter: def set(self) -> WebPageSetter:
"""返回用于设置的对象""" """返回用于设置的对象"""
... ...
@property @property
def wait(self) -> MixPageWaiter: def wait(self) -> WebPageWaiter:
"""返回用于等待的对象""" """返回用于等待的对象"""
... ...

View File

@ -56,7 +56,7 @@ class SessionCookiesSetter(object):
self._owner.session.cookies.clear() self._owner.session.cookies.clear()
class MixPageCookiesSetter(CookiesSetter, SessionCookiesSetter): class WebPageCookiesSetter(CookiesSetter, SessionCookiesSetter):
def __call__(self, cookies): def __call__(self, cookies):
if self._owner.mode == 'd' and self._owner._has_driver: if self._owner.mode == 'd' and self._owner._has_driver:

View File

@ -10,9 +10,9 @@ from typing import Union
from .._base.chromium import Chromium from .._base.chromium import Chromium
from .._pages.chromium_base import ChromiumBase from .._pages.chromium_base import ChromiumBase
from .._pages.mix_page import MixPage
from .._pages.mix_tab import MixTab from .._pages.mix_tab import MixTab
from .._pages.session_page import SessionPage from .._pages.session_page import SessionPage
from .._pages.web_page import WebPage
class BrowserCookiesSetter(object): class BrowserCookiesSetter(object):
@ -99,12 +99,12 @@ class SessionCookiesSetter(object):
... ...
class MixPageCookiesSetter(CookiesSetter, SessionCookiesSetter): class WebPageCookiesSetter(CookiesSetter, SessionCookiesSetter):
_owner: Union[MixPage, MixTab] = ... _owner: Union[WebPage, MixTab] = ...
def __init__(self, owner: Union[MixPage, MixTab]): def __init__(self, owner: Union[WebPage, MixTab]):
""" """
:param owner: MixPage, MixTab对象 :param owner: WebPage, MixTab对象
""" """
... ...

View File

@ -12,8 +12,8 @@ from .._pages.chromium_base import ChromiumBase
from .._pages.chromium_frame import ChromiumFrame from .._pages.chromium_frame import ChromiumFrame
from .._pages.chromium_page import ChromiumPage from .._pages.chromium_page import ChromiumPage
from .._pages.chromium_tab import ChromiumTab from .._pages.chromium_tab import ChromiumTab
from .._pages.mix_page import MixPage
from .._pages.mix_tab import MixTab from .._pages.mix_tab import MixTab
from .._pages.web_page import WebPage
class ElementRect(object): class ElementRect(object):
@ -110,7 +110,7 @@ class TabRect(object):
""" """
:param owner: Page对象和Tab对象 :param owner: Page对象和Tab对象
""" """
self._owner: Union[ChromiumPage, ChromiumTab, MixPage, MixTab] = ... self._owner: Union[ChromiumPage, ChromiumTab, WebPage, MixTab] = ...
@property @property
def window_state(self) -> str: def window_state(self) -> str:

View File

@ -12,8 +12,8 @@ from .._pages.chromium_base import ChromiumBase
from .._pages.chromium_frame import ChromiumFrame from .._pages.chromium_frame import ChromiumFrame
from .._pages.chromium_page import ChromiumPage from .._pages.chromium_page import ChromiumPage
from .._pages.chromium_tab import ChromiumTab from .._pages.chromium_tab import ChromiumTab
from .._pages.mix_page import MixPage
from .._pages.mix_tab import MixTab from .._pages.mix_tab import MixTab
from .._pages.web_page import WebPage
class Scroller(object): class Scroller(object):
@ -186,7 +186,7 @@ class PageScroller(Scroller):
def to_see(self, def to_see(self,
loc_or_ele: Union[str, tuple, ChromiumElement], loc_or_ele: Union[str, tuple, ChromiumElement],
center: Union[bool, None] = None) -> Union[ChromiumTab, MixTab, ChromiumPage, MixPage]: center: Union[bool, None] = None) -> Union[ChromiumTab, MixTab, ChromiumPage, WebPage]:
"""滚动页面直到元素可见 """滚动页面直到元素可见
:param loc_or_ele: 元素的定位信息可以是loc元组或查询字符串 :param loc_or_ele: 元素的定位信息可以是loc元组或查询字符串
:param center: 是否尽量滚动到页面正中为None时如果被遮挡则滚动到页面正中 :param center: 是否尽量滚动到页面正中为None时如果被遮挡则滚动到页面正中
@ -194,27 +194,27 @@ class PageScroller(Scroller):
""" """
... ...
def to_top(self) -> Union[ChromiumTab, MixTab, ChromiumPage, MixPage]: def to_top(self) -> Union[ChromiumTab, MixTab, ChromiumPage, WebPage]:
"""滚动到顶端,水平位置不变""" """滚动到顶端,水平位置不变"""
... ...
def to_bottom(self) -> Union[ChromiumTab, MixTab, ChromiumPage, MixPage]: def to_bottom(self) -> Union[ChromiumTab, MixTab, ChromiumPage, WebPage]:
"""滚动到底端,水平位置不变""" """滚动到底端,水平位置不变"""
... ...
def to_half(self) -> Union[ChromiumTab, MixTab, ChromiumPage, MixPage]: def to_half(self) -> Union[ChromiumTab, MixTab, ChromiumPage, WebPage]:
"""滚动到垂直中间位置,水平位置不变""" """滚动到垂直中间位置,水平位置不变"""
... ...
def to_rightmost(self) -> Union[ChromiumTab, MixTab, ChromiumPage, MixPage]: def to_rightmost(self) -> Union[ChromiumTab, MixTab, ChromiumPage, WebPage]:
"""滚动到最右边,垂直位置不变""" """滚动到最右边,垂直位置不变"""
... ...
def to_leftmost(self) -> Union[ChromiumTab, MixTab, ChromiumPage, MixPage]: def to_leftmost(self) -> Union[ChromiumTab, MixTab, ChromiumPage, WebPage]:
"""滚动到最左边,垂直位置不变""" """滚动到最左边,垂直位置不变"""
... ...
def to_location(self, x: int, y: int) -> Union[ChromiumTab, MixTab, ChromiumPage, MixPage]: def to_location(self, x: int, y: int) -> Union[ChromiumTab, MixTab, ChromiumPage, WebPage]:
"""滚动到指定位置 """滚动到指定位置
:param x: 水平距离 :param x: 水平距离
:param y: 垂直距离 :param y: 垂直距离
@ -222,28 +222,28 @@ class PageScroller(Scroller):
""" """
... ...
def up(self, pixel: int = 300) -> Union[ChromiumTab, MixTab, ChromiumPage, MixPage]: def up(self, pixel: int = 300) -> Union[ChromiumTab, MixTab, ChromiumPage, WebPage]:
"""向上滚动若干像素,水平位置不变 """向上滚动若干像素,水平位置不变
:param pixel: 滚动的像素 :param pixel: 滚动的像素
:return: None :return: None
""" """
... ...
def down(self, pixel: int = 300) -> Union[ChromiumTab, MixTab, ChromiumPage, MixPage]: def down(self, pixel: int = 300) -> Union[ChromiumTab, MixTab, ChromiumPage, WebPage]:
"""向下滚动若干像素,水平位置不变 """向下滚动若干像素,水平位置不变
:param pixel: 滚动的像素 :param pixel: 滚动的像素
:return: None :return: None
""" """
... ...
def left(self, pixel: int = 300) -> Union[ChromiumTab, MixTab, ChromiumPage, MixPage]: def left(self, pixel: int = 300) -> Union[ChromiumTab, MixTab, ChromiumPage, WebPage]:
"""向左滚动若干像素,垂直位置不变 """向左滚动若干像素,垂直位置不变
:param pixel: 滚动的像素 :param pixel: 滚动的像素
:return: None :return: None
""" """
... ...
def right(self, pixel: int = 300) -> Union[ChromiumTab, MixTab, ChromiumPage, MixPage]: def right(self, pixel: int = 300) -> Union[ChromiumTab, MixTab, ChromiumPage, WebPage]:
"""向右滚动若干像素,垂直位置不变 """向右滚动若干像素,垂直位置不变
:param pixel: 滚动的像素 :param pixel: 滚动的像素
:return: None :return: None

View File

@ -10,7 +10,7 @@ from time import sleep
from requests.structures import CaseInsensitiveDict from requests.structures import CaseInsensitiveDict
from .cookies_setter import SessionCookiesSetter, CookiesSetter, MixPageCookiesSetter, BrowserCookiesSetter from .cookies_setter import SessionCookiesSetter, CookiesSetter, WebPageCookiesSetter, BrowserCookiesSetter
from .._functions.tools import show_or_hide_browser from .._functions.tools import show_or_hide_browser
from .._functions.web import format_headers from .._functions.web import format_headers
from ..errors import ElementLostError, JavaScriptError from ..errors import ElementLostError, JavaScriptError
@ -235,8 +235,8 @@ class TabSetter(ChromiumBaseSetter):
self._owner.browser._dl_mgr.set_rename(self._owner.tab_id, name, suffix) self._owner.browser._dl_mgr.set_rename(self._owner.tab_id, name, suffix)
def when_download_file_exists(self, mode): def when_download_file_exists(self, mode):
types = {'rename': 'rename', 'overwrite': 'overwrite', 'skip': 'skip', 'r': 'rename', 'o': 'overwrite', types = {'rename': 'rename', 'overwrite': 'overwrite', 'skip': 'skip',
's': 'skip'} 'r': 'rename', 'o': 'overwrite', 's': 'skip'}
mode = types.get(mode, mode) mode = types.get(mode, mode)
if mode not in types: if mode not in types:
raise ValueError(f'''mode参数只能是 '{"', '".join(types.keys())}' 之一,现在是:{mode}''') raise ValueError(f'''mode参数只能是 '{"', '".join(types.keys())}' 之一,现在是:{mode}''')
@ -266,7 +266,7 @@ class ChromiumPageSetter(TabSetter):
self._owner.browser._download_path = self._owner._download_path self._owner.browser._download_path = self._owner._download_path
class MixPageSetter(ChromiumPageSetter): class WebPageSetter(ChromiumPageSetter):
def __init__(self, owner): def __init__(self, owner):
super().__init__(owner) super().__init__(owner)
self._session_setter = SessionPageSetter(self._owner) self._session_setter = SessionPageSetter(self._owner)
@ -275,7 +275,7 @@ class MixPageSetter(ChromiumPageSetter):
@property @property
def cookies(self): def cookies(self):
if self._cookies_setter is None: if self._cookies_setter is None:
self._cookies_setter = MixPageCookiesSetter(self._owner) self._cookies_setter = WebPageCookiesSetter(self._owner)
return self._cookies_setter return self._cookies_setter
def headers(self, headers): def headers(self, headers):
@ -300,19 +300,19 @@ class MixTabSetter(TabSetter):
@property @property
def cookies(self): def cookies(self):
if self._cookies_setter is None: if self._cookies_setter is None:
self._cookies_setter = MixPageCookiesSetter(self._owner) self._cookies_setter = WebPageCookiesSetter(self._owner)
return self._cookies_setter return self._cookies_setter
def headers(self, headers): def headers(self, headers):
if self._owner._has_session: if self._owner._session:
self._session_setter.headers(headers) self._session_setter.headers(headers)
if self._owner._has_driver: if self._owner._driver and self._owner._driver.is_running:
self._chromium_setter.headers(headers) self._chromium_setter.headers(headers)
def user_agent(self, ua, platform=None): def user_agent(self, ua, platform=None):
if self._owner._has_session: if self._owner._session:
self._session_setter.user_agent(ua) self._session_setter.user_agent(ua)
if self._owner._has_driver: if self._owner._driver and self._owner._driver.is_running:
self._chromium_setter.user_agent(ua, platform) self._chromium_setter.user_agent(ua, platform)
def timeouts(self, base=None, page_load=None, script=None): def timeouts(self, base=None, page_load=None, script=None):
@ -370,7 +370,7 @@ class LoadMode(object):
if value.lower() not in ('normal', 'eager', 'none'): if value.lower() not in ('normal', 'eager', 'none'):
raise ValueError("只能选择 'normal', 'eager', 'none'") raise ValueError("只能选择 'normal', 'eager', 'none'")
self._owner._load_mode = value self._owner._load_mode = value
if self._owner._type in ('ChromiumPage', 'MixPage'): if self._owner._type in ('ChromiumPage', 'WebPage'):
self._owner.browser._load_mode = value self._owner.browser._load_mode = value
def normal(self): def normal(self):

View File

@ -11,7 +11,7 @@ from typing import Union, Tuple, Literal, Any, Optional
from requests.adapters import HTTPAdapter from requests.adapters import HTTPAdapter
from requests.auth import HTTPBasicAuth from requests.auth import HTTPBasicAuth
from .cookies_setter import SessionCookiesSetter, CookiesSetter, MixPageCookiesSetter, BrowserCookiesSetter from .cookies_setter import SessionCookiesSetter, CookiesSetter, WebPageCookiesSetter, BrowserCookiesSetter
from .scroller import PageScroller from .scroller import PageScroller
from .._base.base import BasePage from .._base.base import BasePage
from .._base.chromium import Chromium from .._base.chromium import Chromium
@ -20,9 +20,9 @@ from .._pages.chromium_base import ChromiumBase
from .._pages.chromium_frame import ChromiumFrame from .._pages.chromium_frame import ChromiumFrame
from .._pages.chromium_page import ChromiumPage from .._pages.chromium_page import ChromiumPage
from .._pages.chromium_tab import ChromiumTab from .._pages.chromium_tab import ChromiumTab
from .._pages.mix_page import MixPage
from .._pages.mix_tab import MixTab from .._pages.mix_tab import MixTab
from .._pages.session_page import SessionPage from .._pages.session_page import SessionPage
from .._pages.web_page import WebPage
FILE_EXISTS = Literal['skip', 'rename', 'overwrite', 's', 'r', 'o'] FILE_EXISTS = Literal['skip', 'rename', 'overwrite', 's', 'r', 'o']
@ -403,19 +403,19 @@ class ChromiumPageSetter(TabSetter):
... ...
class MixPageSetter(ChromiumPageSetter): class WebPageSetter(ChromiumPageSetter):
_owner: MixPage = ... _owner: WebPage = ...
_session_setter: SessionPageSetter = ... _session_setter: SessionPageSetter = ...
_chromium_setter: ChromiumPageSetter = ... _chromium_setter: ChromiumPageSetter = ...
def __init__(self, owner: MixPage): def __init__(self, owner: WebPage):
""" """
:param owner: MixPage对象 :param owner: WebPage对象
""" """
... ...
@property @property
def cookies(self) -> MixPageCookiesSetter: def cookies(self) -> WebPageCookiesSetter:
"""返回用于设置cookies的对象""" """返回用于设置cookies的对象"""
... ...
@ -432,7 +432,7 @@ class MixTabSetter(TabSetter):
... ...
@property @property
def cookies(self) -> MixPageCookiesSetter: def cookies(self) -> WebPageCookiesSetter:
"""返回用于设置cookies的对象""" """返回用于设置cookies的对象"""
... ...
@ -535,7 +535,7 @@ class LoadMode(object):
""" """
... ...
def __call__(self, value: str) -> None: def __call__(self, value: Literal['normal', 'eager', 'none']) -> None:
"""设置加载策略 """设置加载策略
:param value: 可选 'normal', 'eager', 'none' :param value: 可选 'normal', 'eager', 'none'
:return: None :return: None

View File

@ -14,8 +14,8 @@ from .._pages.chromium_base import ChromiumBase
from .._pages.chromium_frame import ChromiumFrame from .._pages.chromium_frame import ChromiumFrame
from .._pages.chromium_page import ChromiumPage from .._pages.chromium_page import ChromiumPage
from .._pages.chromium_tab import ChromiumTab from .._pages.chromium_tab import ChromiumTab
from .._pages.mix_page import MixPage
from .._pages.mix_tab import MixTab from .._pages.mix_tab import MixTab
from .._pages.web_page import WebPage
class OriginWaiter(object): class OriginWaiter(object):
@ -349,7 +349,7 @@ class MixTabWaiter(BaseWaiter):
class ChromiumPageWaiter(TabWaiter): class ChromiumPageWaiter(TabWaiter):
_owner: Union[ChromiumPage, MixPage] = ... _owner: Union[ChromiumPage, WebPage] = ...
def __init__(self, owner: ChromiumPage): def __init__(self, owner: ChromiumPage):
""" """
@ -416,10 +416,10 @@ class ChromiumPageWaiter(TabWaiter):
... ...
class MixPageWaiter(TabWaiter): class WebPageWaiter(TabWaiter):
_owner: Union[ChromiumPage, MixPage] = ... _owner: Union[ChromiumPage, WebPage] = ...
def __init__(self, owner: MixPage): def __init__(self, owner: WebPage):
""" """
:param owner: Page对象 :param owner: Page对象
""" """
@ -427,7 +427,7 @@ class MixPageWaiter(TabWaiter):
def __call__(self, def __call__(self,
second: float, second: float,
scope: float = None) -> MixPage: scope: float = None) -> WebPage:
"""等待若干秒,如传入两个参数,等待时间为这两个数间的一个随机数 """等待若干秒,如传入两个参数,等待时间为这两个数间的一个随机数
:param second: 秒数 :param second: 秒数
:param scope: 随机数范围 :param scope: 随机数范围
@ -459,7 +459,7 @@ class MixPageWaiter(TabWaiter):
text: str, text: str,
exclude: bool = False, exclude: bool = False,
timeout: float = None, timeout: float = None,
raise_err: bool = None) -> Union[False, MixPage]: raise_err: bool = None) -> Union[False, WebPage]:
"""等待url变成包含或不包含指定文本 """等待url变成包含或不包含指定文本
:param text: 用于识别的文本 :param text: 用于识别的文本
:param exclude: 是否排除为True时当url不包含text指定文本时返回True :param exclude: 是否排除为True时当url不包含text指定文本时返回True
@ -473,7 +473,7 @@ class MixPageWaiter(TabWaiter):
text: str, text: str,
exclude: bool = False, exclude: bool = False,
timeout: float = None, timeout: float = None,
raise_err: bool = None) -> Union[False, MixPage]: raise_err: bool = None) -> Union[False, WebPage]:
"""等待title变成包含或不包含指定文本 """等待title变成包含或不包含指定文本
:param text: 用于识别的文本 :param text: 用于识别的文本
:param exclude: 是否排除为True时当title不包含text指定文本时返回True :param exclude: 是否排除为True时当title不包含text指定文本时返回True

View File

@ -13,7 +13,6 @@ from ._functions.keys import Keys
from ._functions.settings import Settings from ._functions.settings import Settings
from ._functions.tools import wait_until, configs_to_here from ._functions.tools import wait_until, configs_to_here
from ._functions.web import get_blob, tree from ._functions.web import get_blob, tree
from ._units.actions import Actions from ._units.actions import Actions
__all__ = ['make_session_ele', 'Actions', 'Keys', 'By', 'Settings', 'wait_until', 'configs_to_here', 'get_blob', __all__ = ['make_session_ele', 'Actions', 'Keys', 'By', 'Settings', 'wait_until', 'configs_to_here', 'get_blob',