mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
添加存根文件
This commit is contained in:
parent
af4ed1eaa4
commit
d210db2844
@ -1,9 +1,7 @@
|
|||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from typing import Union, Tuple
|
|
||||||
|
|
||||||
from .common import _location_in_viewport
|
from .common import _location_in_viewport
|
||||||
from .base import DrissionElement
|
|
||||||
from .keys import _modifierBit, _keyDescriptionForString
|
from .keys import _modifierBit, _keyDescriptionForString
|
||||||
|
|
||||||
|
|
||||||
@ -12,7 +10,7 @@ class ActionChains:
|
|||||||
|
|
||||||
def __init__(self, page):
|
def __init__(self, page):
|
||||||
"""初始化 \n
|
"""初始化 \n
|
||||||
:param page: ChromePage对象
|
:param page: ChromiumPage对象
|
||||||
"""
|
"""
|
||||||
self.page = page
|
self.page = page
|
||||||
self._dr = page.driver
|
self._dr = page.driver
|
||||||
@ -20,7 +18,7 @@ class ActionChains:
|
|||||||
self.curr_x = 0 # 视口坐标
|
self.curr_x = 0 # 视口坐标
|
||||||
self.curr_y = 0
|
self.curr_y = 0
|
||||||
|
|
||||||
def move_to(self, ele_or_loc: Union[DrissionElement, Tuple[int, int]],
|
def move_to(self, ele_or_loc,
|
||||||
offset_x: int = 0, offset_y: int = 0) -> 'ActionChains':
|
offset_x: int = 0, offset_y: int = 0) -> 'ActionChains':
|
||||||
"""鼠标移动到元素中点,或页面上的某个绝对坐标。可设置偏移量 \n
|
"""鼠标移动到元素中点,或页面上的某个绝对坐标。可设置偏移量 \n
|
||||||
当带偏移量时,偏移量相对于元素左上角坐标
|
当带偏移量时,偏移量相对于元素左上角坐标
|
||||||
@ -32,7 +30,7 @@ class ActionChains:
|
|||||||
if isinstance(ele_or_loc, (tuple, list)):
|
if isinstance(ele_or_loc, (tuple, list)):
|
||||||
lx = ele_or_loc[0] + offset_x
|
lx = ele_or_loc[0] + offset_x
|
||||||
ly = ele_or_loc[1] + offset_y
|
ly = ele_or_loc[1] + offset_y
|
||||||
elif isinstance(ele_or_loc, DrissionElement):
|
elif 'ChromiumElement' in str(type(ele_or_loc)):
|
||||||
ele_loc = ele_or_loc.location if offset_x or offset_y else ele_or_loc.midpoint
|
ele_loc = ele_or_loc.location if offset_x or offset_y else ele_or_loc.midpoint
|
||||||
lx = ele_loc['x'] + offset_x
|
lx = ele_loc['x'] + offset_x
|
||||||
ly = ele_loc['y'] + offset_y
|
ly = ele_loc['y'] + offset_y
|
||||||
|
@ -1,18 +1,22 @@
|
|||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
from time import sleep
|
|
||||||
from typing import Union, Tuple
|
from typing import Union, Tuple
|
||||||
|
|
||||||
from .common import _location_in_viewport
|
from .tab import Tab
|
||||||
from .base import DrissionElement
|
from .chromium_element import ChromiumElement
|
||||||
from .keys import _modifierBit, _keyDescriptionForString
|
from .chromium_page import ChromiumPage
|
||||||
|
|
||||||
|
|
||||||
class ActionChains:
|
class ActionChains:
|
||||||
"""用于实现动作链的类"""
|
"""用于实现动作链的类"""
|
||||||
|
|
||||||
def __init__(self, page):...
|
def __init__(self, page):
|
||||||
|
self.page: ChromiumPage = ...
|
||||||
|
self._dr: Tab = ...
|
||||||
|
self.curr_x: int = ...
|
||||||
|
self.curr_y: int = ...
|
||||||
|
self.modifier: int = ...
|
||||||
|
|
||||||
def move_to(self, ele_or_loc: Union[DrissionElement, Tuple[int, int]],
|
def move_to(self, ele_or_loc: Union[ChromiumElement, Tuple[int, int]],
|
||||||
offset_x: int = ..., offset_y: int = ...) -> 'ActionChains': ...
|
offset_x: int = ..., offset_y: int = ...) -> 'ActionChains': ...
|
||||||
|
|
||||||
def move(self, offset_x: int = ..., offset_y: int = ...) -> 'ActionChains': ...
|
def move(self, offset_x: int = ..., offset_y: int = ...) -> 'ActionChains': ...
|
||||||
|
@ -76,7 +76,8 @@ class BaseElement(BaseParser):
|
|||||||
|
|
||||||
|
|
||||||
class DrissionElement(BaseElement):
|
class DrissionElement(BaseElement):
|
||||||
"""DriverElement 和 SessionElement的基类,但不是ShadowRootElement的基类"""
|
"""DriverElement、ChromiumElement 和 SessionElement的基类
|
||||||
|
但不是ShadowRootElement的基类"""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def link(self) -> str:
|
def link(self) -> str:
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
"""
|
|
||||||
@Author : g1879
|
|
||||||
@Contact : g1879@qq.com
|
|
||||||
@File : base.py
|
|
||||||
"""
|
|
||||||
from abc import abstractmethod
|
from abc import abstractmethod
|
||||||
from typing import Union, Tuple, List
|
from typing import Union, Tuple, List
|
||||||
|
|
||||||
|
from selenium.webdriver.remote.webelement import WebElement
|
||||||
|
|
||||||
|
from .driver_page import DriverPage
|
||||||
|
from .mix_page import MixPage
|
||||||
|
|
||||||
|
|
||||||
class BaseParser(object):
|
class BaseParser(object):
|
||||||
"""所有页面、元素类的基类"""
|
"""所有页面、元素类的基类"""
|
||||||
@ -32,7 +32,7 @@ class BaseParser(object):
|
|||||||
class BaseElement(BaseParser):
|
class BaseElement(BaseParser):
|
||||||
"""各元素类的基类"""
|
"""各元素类的基类"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, page: BasePage):
|
||||||
self.page: BasePage = ...
|
self.page: BasePage = ...
|
||||||
|
|
||||||
# ----------------以下属性或方法由后代实现----------------
|
# ----------------以下属性或方法由后代实现----------------
|
||||||
@ -67,7 +67,8 @@ class BaseElement(BaseParser):
|
|||||||
class DrissionElement(BaseElement):
|
class DrissionElement(BaseElement):
|
||||||
"""DriverElement 和 SessionElement的基类,但不是ShadowRootElement的基类"""
|
"""DriverElement 和 SessionElement的基类,但不是ShadowRootElement的基类"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self,
|
||||||
|
page: BasePage = ...):
|
||||||
self.page: BasePage = ...
|
self.page: BasePage = ...
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -8,12 +8,11 @@ from urllib.parse import urlparse
|
|||||||
from requests import Session
|
from requests import Session
|
||||||
from requests.cookies import RequestsCookieJar
|
from requests.cookies import RequestsCookieJar
|
||||||
|
|
||||||
from .chromium_element import ChromiumElementWaiter, ChromeScroll
|
|
||||||
from .common import get_loc
|
|
||||||
from .session_element import SessionElement, make_session_ele
|
|
||||||
from .chromium_element import ChromiumElement, _run_script
|
|
||||||
from .config import DriverOptions, _cookies_to_tuple
|
|
||||||
from .base import BasePage
|
from .base import BasePage
|
||||||
|
from .chromium_element import ChromiumElementWaiter, ChromeScroll, ChromiumElement, _run_script
|
||||||
|
from .common import get_loc
|
||||||
|
from .config import DriverOptions, _cookies_to_tuple
|
||||||
|
from .session_element import SessionElement, make_session_ele
|
||||||
from .tab import Tab
|
from .tab import Tab
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Union, Tuple, List, Any
|
from typing import Union, Tuple, List, Any
|
||||||
|
|
||||||
|
from .chromium_base import ChromiumBase
|
||||||
from .chromium_page import ChromiumPage
|
from .chromium_page import ChromiumPage
|
||||||
from .web_page import WebPage
|
from .web_page import WebPage
|
||||||
from .base import DrissionElement, BaseElement
|
from .base import DrissionElement, BaseElement
|
||||||
@ -16,13 +17,16 @@ from .session_element import SessionElement
|
|||||||
class ChromiumElement(DrissionElement):
|
class ChromiumElement(DrissionElement):
|
||||||
"""ChromePage页面对象中的元素对象"""
|
"""ChromePage页面对象中的元素对象"""
|
||||||
|
|
||||||
def __init__(self, page, node_id: str = None, obj_id: str = None):
|
def __init__(self,
|
||||||
self._tag :str=...
|
page: ChromiumBase,
|
||||||
self.page: Union[ChromiumPage, WebPage]=...
|
node_id: str = None,
|
||||||
self._node_id:str=...
|
obj_id: str = None):
|
||||||
self._obj_id:str=...
|
self._tag: str = ...
|
||||||
self._scroll:ChromeScroll=...
|
self.page: Union[ChromiumPage, WebPage] = ...
|
||||||
self._select:ChromeSelect=...
|
self._node_id: str = ...
|
||||||
|
self._obj_id: str = ...
|
||||||
|
self._scroll: ChromeScroll = ...
|
||||||
|
self._select: ChromeSelect = ...
|
||||||
|
|
||||||
def __repr__(self) -> str: ...
|
def __repr__(self) -> str: ...
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ from requests import Session
|
|||||||
from .chromium_base import Timeout, ChromiumBase
|
from .chromium_base import Timeout, ChromiumBase
|
||||||
from .chromium_tab import ChromiumTab
|
from .chromium_tab import ChromiumTab
|
||||||
from .config import DriverOptions
|
from .config import DriverOptions
|
||||||
from .drission import connect_chrome
|
from .common import connect_chrome
|
||||||
from .tab import Tab
|
from .tab import Tab
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
from typing import Union
|
|
||||||
|
|
||||||
from .chromium_page import ChromiumPage
|
|
||||||
from .tab import Tab
|
|
||||||
from .chromium_base import ChromiumBase
|
from .chromium_base import ChromiumBase
|
||||||
|
from .chromium_page import ChromiumPage
|
||||||
|
|
||||||
|
|
||||||
class ChromiumTab(ChromiumBase):
|
class ChromiumTab(ChromiumBase):
|
||||||
|
92
DrissionPage/drission.pyi
Normal file
92
DrissionPage/drission.pyi
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
# -*- encoding: utf-8 -*-
|
||||||
|
from subprocess import Popen
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
|
from requests import Session
|
||||||
|
from requests.cookies import RequestsCookieJar
|
||||||
|
from selenium.webdriver.chrome.options import Options
|
||||||
|
from selenium.webdriver.chrome.webdriver import WebDriver
|
||||||
|
from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
|
||||||
|
|
||||||
|
from .config import SessionOptions, DriverOptions
|
||||||
|
|
||||||
|
|
||||||
|
class Drission(object):
|
||||||
|
"""Drission类用于管理WebDriver对象和Session对象,是驱动器的角色"""
|
||||||
|
|
||||||
|
def __init__(self,
|
||||||
|
driver_or_options: Union[RemoteWebDriver, Options, DriverOptions, bool] = ...,
|
||||||
|
session_or_options: Union[Session, dict, SessionOptions, bool] = ...,
|
||||||
|
ini_path: str = ...,
|
||||||
|
proxy: dict = ...):
|
||||||
|
self._session: Session = ...
|
||||||
|
self._session_options: dict = ...
|
||||||
|
self._proxy: dict = ...
|
||||||
|
self._driver: WebDriver = ...
|
||||||
|
self._debugger: Popen = ...
|
||||||
|
self._driver_options: DriverOptions = ...
|
||||||
|
|
||||||
|
def __del__(self): ...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def session(self) -> Session: ...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def driver(self) -> WebDriver: ...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def driver_options(self) -> Union[DriverOptions, Options]: ...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def session_options(self) -> dict: ...
|
||||||
|
|
||||||
|
@session_options.setter
|
||||||
|
def session_options(self, options: Union[dict, SessionOptions]) -> None: ...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def proxy(self) -> Union[None, dict]: ...
|
||||||
|
|
||||||
|
@proxy.setter
|
||||||
|
def proxy(self, proxies: dict = ...) -> None: ...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def debugger_progress(self): ...
|
||||||
|
|
||||||
|
def kill_browser(self) -> None: ...
|
||||||
|
|
||||||
|
def get_browser_progress_id(self) -> Union[str, None]: ...
|
||||||
|
|
||||||
|
def hide_browser(self) -> None: ...
|
||||||
|
|
||||||
|
def show_browser(self) -> None: ...
|
||||||
|
|
||||||
|
def _show_or_hide_browser(self, hide: bool = ...) -> None: ...
|
||||||
|
|
||||||
|
def set_cookies(self,
|
||||||
|
cookies: Union[RequestsCookieJar, list, tuple, str, dict],
|
||||||
|
set_session: bool = ...,
|
||||||
|
set_driver: bool = ...) -> None: ...
|
||||||
|
|
||||||
|
def _set_session(self, data: dict) -> None: ...
|
||||||
|
|
||||||
|
def cookies_to_session(self, copy_user_agent: bool = False) -> None: ...
|
||||||
|
|
||||||
|
def cookies_to_driver(self, url: str) -> None: ...
|
||||||
|
|
||||||
|
def close_driver(self, kill: bool = ...) -> None: ...
|
||||||
|
|
||||||
|
def close_session(self) -> None: ...
|
||||||
|
|
||||||
|
def close(self) -> None: ...
|
||||||
|
|
||||||
|
|
||||||
|
def user_agent_to_session(driver: RemoteWebDriver, session: Session) -> None: ...
|
||||||
|
|
||||||
|
|
||||||
|
def _create_driver(chrome_path: str, driver_path: str, options: Options) -> WebDriver: ...
|
||||||
|
|
||||||
|
|
||||||
|
def _get_chrome_hwnds_from_pid(pid) -> list: ...
|
||||||
|
|
||||||
|
|
||||||
|
def _kill_progress(pid: str = ..., port: int = ...) -> bool: ...
|
@ -11,7 +11,6 @@ from typing import Union, List, Any, Tuple
|
|||||||
|
|
||||||
from selenium.common.exceptions import TimeoutException, JavascriptException, InvalidElementStateException, \
|
from selenium.common.exceptions import TimeoutException, JavascriptException, InvalidElementStateException, \
|
||||||
NoSuchElementException
|
NoSuchElementException
|
||||||
# from selenium.webdriver.chrome.webdriver import WebDriver
|
|
||||||
from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
|
from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
|
||||||
from selenium.webdriver.remote.webelement import WebElement
|
from selenium.webdriver.remote.webelement import WebElement
|
||||||
from selenium.webdriver.support import expected_conditions as ec
|
from selenium.webdriver.support import expected_conditions as ec
|
||||||
@ -979,9 +978,9 @@ class Select(object):
|
|||||||
if ele.tag != 'select':
|
if ele.tag != 'select':
|
||||||
raise TypeError(f"select方法只能在<select>元素使用,现在是:{ele.tag}。")
|
raise TypeError(f"select方法只能在<select>元素使用,现在是:{ele.tag}。")
|
||||||
|
|
||||||
from selenium.webdriver.support.select import Select
|
from selenium.webdriver.support.select import Select as SeleniumSelect
|
||||||
self.inner_ele = ele
|
self.inner_ele = ele
|
||||||
self.select_ele = Select(ele.inner_ele)
|
self.select_ele = SeleniumSelect(ele.inner_ele)
|
||||||
|
|
||||||
def __call__(self, text_or_index: Union[str, int, list, tuple], timeout=None) -> bool:
|
def __call__(self, text_or_index: Union[str, int, list, tuple], timeout=None) -> bool:
|
||||||
"""选定下拉列表中子元素 \n
|
"""选定下拉列表中子元素 \n
|
||||||
|
401
DrissionPage/driver_element.pyi
Normal file
401
DrissionPage/driver_element.pyi
Normal file
@ -0,0 +1,401 @@
|
|||||||
|
# -*- coding:utf-8 -*-
|
||||||
|
from typing import Union, List, Any, Tuple
|
||||||
|
|
||||||
|
from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
|
||||||
|
from selenium.webdriver.remote.webelement import WebElement
|
||||||
|
from selenium.webdriver.support.select import Select as SeleniumSelect
|
||||||
|
|
||||||
|
from .driver_page import DriverPage
|
||||||
|
from .mix_page import MixPage
|
||||||
|
from .shadow_root_element import ShadowRootElement
|
||||||
|
from .base import DrissionElement
|
||||||
|
from .session_element import SessionElement
|
||||||
|
|
||||||
|
|
||||||
|
class DriverElement(DrissionElement):
|
||||||
|
"""driver模式的元素对象,包装了一个WebElement对象,并封装了常用功能"""
|
||||||
|
|
||||||
|
def __init__(self, ele: WebElement, page=...):
|
||||||
|
self._inner_ele: WebElement = ...
|
||||||
|
self._select: Select = ...
|
||||||
|
self._scroll: Scroll = ...
|
||||||
|
self.page: Union[DriverPage, MixPage] = ...
|
||||||
|
|
||||||
|
def __repr__(self) -> str:
|
||||||
|
...
|
||||||
|
|
||||||
|
def __call__(self,
|
||||||
|
loc_or_str: Union[Tuple[str, str], str],
|
||||||
|
timeout: float = ...) -> Union['DriverElement', str, None]:
|
||||||
|
...
|
||||||
|
|
||||||
|
# -----------------共有属性和方法-------------------
|
||||||
|
@property
|
||||||
|
def inner_ele(self) -> WebElement:
|
||||||
|
...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def tag(self) -> str:
|
||||||
|
...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def html(self) -> str:
|
||||||
|
...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def inner_html(self) -> str:
|
||||||
|
...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def attrs(self) -> dict:
|
||||||
|
...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def text(self) -> str:
|
||||||
|
...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def raw_text(self) -> str:
|
||||||
|
...
|
||||||
|
|
||||||
|
def attr(self, attr: str) -> str:
|
||||||
|
...
|
||||||
|
|
||||||
|
def ele(self,
|
||||||
|
loc_or_str: Union[Tuple[str, str], str],
|
||||||
|
timeout: float = ...) -> Union['DriverElement', str, None]:
|
||||||
|
...
|
||||||
|
|
||||||
|
def eles(self,
|
||||||
|
loc_or_str: Union[Tuple[str, str], str],
|
||||||
|
timeout: float = ...) -> List[Union['DriverElement', str]]:
|
||||||
|
...
|
||||||
|
|
||||||
|
def s_ele(self, loc_or_str: Union[Tuple[str, str], str] = ...) -> Union[SessionElement, str, None]:
|
||||||
|
...
|
||||||
|
|
||||||
|
def s_eles(self, loc_or_str: Union[Tuple[str, str], str] = ...) -> List[Union[SessionElement, str]]:
|
||||||
|
...
|
||||||
|
|
||||||
|
def _ele(self,
|
||||||
|
loc_or_str: Union[Tuple[str, str], str],
|
||||||
|
timeout: float = ...,
|
||||||
|
single: bool = ...,
|
||||||
|
relative: bool = ...) -> Union['DriverElement', str, None, List[Union['DriverElement', str]]]:
|
||||||
|
...
|
||||||
|
|
||||||
|
def _get_ele_path(self, mode) -> str:
|
||||||
|
...
|
||||||
|
|
||||||
|
# -----------------driver独有属性和方法-------------------
|
||||||
|
@property
|
||||||
|
def size(self) -> dict:
|
||||||
|
...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def location(self) -> dict:
|
||||||
|
...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def shadow_root(self) -> ShadowRootElement:
|
||||||
|
...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def sr(self) -> ShadowRootElement:
|
||||||
|
...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def pseudo_before(self) -> str:
|
||||||
|
...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def pseudo_after(self) -> str:
|
||||||
|
...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def select(self) -> Select:
|
||||||
|
...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def scroll(self) -> Scroll:
|
||||||
|
...
|
||||||
|
|
||||||
|
def parent(self, level_or_loc: Union[tuple, str, int] = ...) -> Union['DriverElement', None]:
|
||||||
|
...
|
||||||
|
|
||||||
|
def prev(self,
|
||||||
|
index: int = ...,
|
||||||
|
filter_loc: Union[tuple, str] = ...,
|
||||||
|
timeout: float = ...) -> Union['DriverElement', str, None]:
|
||||||
|
...
|
||||||
|
|
||||||
|
def next(self,
|
||||||
|
index: int = ...,
|
||||||
|
filter_loc: Union[tuple, str] = ...,
|
||||||
|
timeout: float = ...) -> Union['DriverElement', str, None]:
|
||||||
|
...
|
||||||
|
|
||||||
|
def before(self,
|
||||||
|
index: int = ...,
|
||||||
|
filter_loc: Union[tuple, str] = ...,
|
||||||
|
timeout: float = ...) -> Union['DriverElement', str, None]:
|
||||||
|
...
|
||||||
|
|
||||||
|
def after(self,
|
||||||
|
index: int = ...,
|
||||||
|
filter_loc: Union[tuple, str] = ...,
|
||||||
|
timeout: float = ...) -> Union['DriverElement', str, None]:
|
||||||
|
...
|
||||||
|
|
||||||
|
def prevs(self,
|
||||||
|
filter_loc: Union[tuple, str] = ...,
|
||||||
|
timeout: float = ...) -> List[Union['DriverElement', str]]:
|
||||||
|
...
|
||||||
|
|
||||||
|
def nexts(self,
|
||||||
|
filter_loc: Union[tuple, str] = ...,
|
||||||
|
timeout: float = ...) -> List[Union['DriverElement', str]]:
|
||||||
|
...
|
||||||
|
|
||||||
|
def befores(self,
|
||||||
|
filter_loc: Union[tuple, str] = ...,
|
||||||
|
timeout: float = ...) -> List[Union['DriverElement', str]]:
|
||||||
|
...
|
||||||
|
|
||||||
|
def afters(self,
|
||||||
|
filter_loc: Union[tuple, str] = ...,
|
||||||
|
timeout: float = ...) -> List[Union['DriverElement', str]]:
|
||||||
|
...
|
||||||
|
|
||||||
|
def left(self, index: int = ..., filter_loc: Union[tuple, str] = ...) -> DriverElement:
|
||||||
|
...
|
||||||
|
|
||||||
|
def right(self, index: int = ..., filter_loc: Union[tuple, str] = ...) -> 'DriverElement':
|
||||||
|
...
|
||||||
|
|
||||||
|
def above(self, index: int = ..., filter_loc: Union[tuple, str] = ...) -> 'DriverElement':
|
||||||
|
...
|
||||||
|
|
||||||
|
def below(self, index: int = ..., filter_loc: Union[tuple, str] = ...) -> 'DriverElement':
|
||||||
|
...
|
||||||
|
|
||||||
|
def near(self, index: int = ..., filter_loc: Union[tuple, str] = ...) -> 'DriverElement':
|
||||||
|
...
|
||||||
|
|
||||||
|
def lefts(self, filter_loc: Union[tuple, str] = ...) -> List['DriverElement']:
|
||||||
|
...
|
||||||
|
|
||||||
|
def rights(self, filter_loc: Union[tuple, str] = ...) -> List['DriverElement']:
|
||||||
|
...
|
||||||
|
|
||||||
|
def aboves(self, filter_loc: Union[tuple, str] = ...) -> List['DriverElement']:
|
||||||
|
...
|
||||||
|
|
||||||
|
def belows(self, filter_loc: Union[tuple, str] = ...) -> List['DriverElement']:
|
||||||
|
...
|
||||||
|
|
||||||
|
def nears(self, filter_loc: Union[tuple, str] = ...) -> List['DriverElement']:
|
||||||
|
...
|
||||||
|
|
||||||
|
def wait_ele(self,
|
||||||
|
loc_or_ele: Union[str, tuple, DrissionElement, WebElement],
|
||||||
|
timeout: float = ...) -> 'ElementWaiter':
|
||||||
|
...
|
||||||
|
|
||||||
|
def style(self, style: str, pseudo_ele: str = ...) -> str:
|
||||||
|
...
|
||||||
|
|
||||||
|
def click(self, by_js: bool = ..., timeout: float = ...) -> bool:
|
||||||
|
...
|
||||||
|
|
||||||
|
def click_at(self,
|
||||||
|
x: Union[int, str] = ...,
|
||||||
|
y: Union[int, str] = ...,
|
||||||
|
by_js: bool = ...) -> None:
|
||||||
|
...
|
||||||
|
|
||||||
|
def r_click(self) -> None:
|
||||||
|
...
|
||||||
|
|
||||||
|
def r_click_at(self, x: Union[int, str] = ..., y: Union[int, str] = ...) -> None:
|
||||||
|
...
|
||||||
|
|
||||||
|
def input(self,
|
||||||
|
vals: Union[str, tuple],
|
||||||
|
clear: bool = ...,
|
||||||
|
insure: bool = ...,
|
||||||
|
timeout: float = ...) -> bool:
|
||||||
|
...
|
||||||
|
|
||||||
|
def run_script(self, script: str, *args) -> Any:
|
||||||
|
...
|
||||||
|
|
||||||
|
def submit(self) -> Union[bool, None]:
|
||||||
|
...
|
||||||
|
|
||||||
|
def clear(self, insure: bool = ...) -> Union[None, bool]:
|
||||||
|
...
|
||||||
|
|
||||||
|
def is_selected(self) -> bool:
|
||||||
|
...
|
||||||
|
|
||||||
|
def is_enabled(self) -> bool:
|
||||||
|
...
|
||||||
|
|
||||||
|
def is_displayed(self) -> bool:
|
||||||
|
...
|
||||||
|
|
||||||
|
def is_valid(self) -> bool:
|
||||||
|
...
|
||||||
|
|
||||||
|
def screenshot(self, path: str = ..., filename: str = ..., as_bytes: bool = ...) -> Union[str, bytes]:
|
||||||
|
...
|
||||||
|
|
||||||
|
def prop(self, prop: str) -> str:
|
||||||
|
...
|
||||||
|
|
||||||
|
def set_prop(self, prop: str, value: str) -> bool:
|
||||||
|
...
|
||||||
|
|
||||||
|
def set_attr(self, attr: str, value: str) -> bool:
|
||||||
|
...
|
||||||
|
|
||||||
|
def remove_attr(self, attr: str) -> bool:
|
||||||
|
"""删除元素attribute属性 \n
|
||||||
|
:param attr: 属性名
|
||||||
|
:return: 是否删除成功
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
self.run_script(f'arguments[0].removeAttribute("{attr}");')
|
||||||
|
return True
|
||||||
|
except Exception:
|
||||||
|
return False
|
||||||
|
|
||||||
|
def drag(self, x: int, y: int, speed: int = ..., shake: bool = ...) -> None:
|
||||||
|
...
|
||||||
|
|
||||||
|
def drag_to(self,
|
||||||
|
ele_or_loc: Union[tuple, WebElement, DrissionElement],
|
||||||
|
speed: int = ...,
|
||||||
|
shake: bool = ...) -> None:
|
||||||
|
...
|
||||||
|
|
||||||
|
def hover(self, x: int = ..., y: int = ...) -> None:
|
||||||
|
...
|
||||||
|
|
||||||
|
def _get_relative_eles(self,
|
||||||
|
mode: str,
|
||||||
|
loc: Union[tuple, str] = ...) -> Union[List['DriverElement'], 'DriverElement']:
|
||||||
|
...
|
||||||
|
|
||||||
|
|
||||||
|
def make_driver_ele(page_or_ele,
|
||||||
|
loc: Union[str, Tuple[str, str]],
|
||||||
|
single: bool = ...,
|
||||||
|
timeout: float = ...) -> Union[DriverElement, str, None, List[Union[DriverElement, str]]]: ...
|
||||||
|
|
||||||
|
|
||||||
|
class ElementsByXpath(object):
|
||||||
|
"""用js通过xpath获取元素、节点或属性,与WebDriverWait配合使用"""
|
||||||
|
|
||||||
|
def __init__(self, page, xpath: str = ..., single: bool = ..., timeout: float = ...):
|
||||||
|
self.single: bool = ...
|
||||||
|
self.xpath: str = ...
|
||||||
|
self.page: Union[MixPage, DriverPage] = ...
|
||||||
|
|
||||||
|
def __call__(self, ele_or_driver: Union[RemoteWebDriver, WebElement]) \
|
||||||
|
-> Union[str, DriverElement, None, List[str or DriverElement]]: ...
|
||||||
|
|
||||||
|
|
||||||
|
class Select(object):
|
||||||
|
"""Select 类专门用于处理 d 模式下 select 标签"""
|
||||||
|
|
||||||
|
def __init__(self, ele: DriverElement):
|
||||||
|
self.select_ele: SeleniumSelect = ...
|
||||||
|
self.inner_ele: DriverElement = ...
|
||||||
|
|
||||||
|
def __call__(self, text_or_index: Union[str, int, list, tuple], timeout=...) -> bool: ...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_multi(self) -> bool: ...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def options(self) -> List[DriverElement]: ...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def selected_option(self) -> Union[DriverElement, None]: ...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def selected_options(self) -> List[DriverElement]: ...
|
||||||
|
|
||||||
|
def clear(self) -> None: ...
|
||||||
|
|
||||||
|
def select(self, text_or_index: Union[str, int, list, tuple], timeout=...) -> bool: ...
|
||||||
|
|
||||||
|
def select_by_value(self, value: Union[str, list, tuple], timeout=...) -> bool: ...
|
||||||
|
|
||||||
|
def deselect(self, text_or_index: Union[str, int, list, tuple], timeout=...) -> bool: ...
|
||||||
|
|
||||||
|
def deselect_by_value(self, value: Union[str, list, tuple], timeout=...) -> bool: ...
|
||||||
|
|
||||||
|
def invert(self) -> None: ...
|
||||||
|
|
||||||
|
def _select(self,
|
||||||
|
text_value_index: Union[str, int, list, tuple] = ...,
|
||||||
|
para_type: str = ...,
|
||||||
|
deselect: bool = ...,
|
||||||
|
timeout: float = ...) -> bool: ...
|
||||||
|
|
||||||
|
def _select_multi(self,
|
||||||
|
text_value_index: Union[list, tuple] = ...,
|
||||||
|
para_type: str = ...,
|
||||||
|
deselect: bool = ...) -> bool: ...
|
||||||
|
|
||||||
|
|
||||||
|
class ElementWaiter(object):
|
||||||
|
"""等待元素在dom中某种状态,如删除、显示、隐藏"""
|
||||||
|
|
||||||
|
def __init__(self,
|
||||||
|
page_or_ele,
|
||||||
|
loc_or_ele: Union[str, tuple, DriverElement, WebElement],
|
||||||
|
timeout: float = ...):
|
||||||
|
self.target: Union[DriverElement, WebElement, tuple] = ...
|
||||||
|
self.timeout: float = ...
|
||||||
|
self.driver: Union[WebElement, RemoteWebDriver] = ...
|
||||||
|
|
||||||
|
def delete(self) -> bool: ...
|
||||||
|
|
||||||
|
def display(self) -> bool: ...
|
||||||
|
|
||||||
|
def hidden(self) -> bool: ...
|
||||||
|
|
||||||
|
def _wait_ele(self, mode: str) -> bool: ...
|
||||||
|
|
||||||
|
|
||||||
|
class Scroll(object):
|
||||||
|
"""用于滚动的对象"""
|
||||||
|
|
||||||
|
def __init__(self, page_or_ele):
|
||||||
|
self.driver: Union[DriverElement, DriverPage] = ...
|
||||||
|
self.t1: str = ...
|
||||||
|
self.t2: str = ...
|
||||||
|
|
||||||
|
def to_top(self) -> None: ...
|
||||||
|
|
||||||
|
def to_bottom(self) -> None: ...
|
||||||
|
|
||||||
|
def to_half(self) -> None: ...
|
||||||
|
|
||||||
|
def to_rightmost(self) -> None: ...
|
||||||
|
|
||||||
|
def to_leftmost(self) -> None: ...
|
||||||
|
|
||||||
|
def to_location(self, x: int, y: int) -> None: ...
|
||||||
|
|
||||||
|
def up(self, pixel: int = ...) -> None: ...
|
||||||
|
|
||||||
|
def down(self, pixel: int = ...) -> None: ...
|
||||||
|
|
||||||
|
def left(self, pixel: int = ...) -> None: ...
|
||||||
|
|
||||||
|
def right(self, pixel: int = ...) -> None: ...
|
191
DrissionPage/driver_page.pyi
Normal file
191
DrissionPage/driver_page.pyi
Normal file
@ -0,0 +1,191 @@
|
|||||||
|
# -*- coding:utf-8 -*-
|
||||||
|
from glob import glob
|
||||||
|
from os import sep
|
||||||
|
from pathlib import Path
|
||||||
|
from time import sleep, perf_counter
|
||||||
|
from typing import Union, List, Any, Tuple
|
||||||
|
|
||||||
|
from selenium.common.exceptions import NoAlertPresentException
|
||||||
|
from selenium.webdriver.chrome.webdriver import WebDriver
|
||||||
|
from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
|
||||||
|
from selenium.webdriver.remote.webelement import WebElement
|
||||||
|
from selenium.webdriver.support.wait import WebDriverWait
|
||||||
|
|
||||||
|
from .base import BasePage
|
||||||
|
from .common import get_usable_path
|
||||||
|
from .driver_element import DriverElement, make_driver_ele, Scroll, ElementWaiter
|
||||||
|
from .session_element import make_session_ele, SessionElement
|
||||||
|
|
||||||
|
|
||||||
|
class DriverPage(BasePage):
|
||||||
|
"""DriverPage封装了页面操作的常用功能,使用selenium来获取、解析、操作网页"""
|
||||||
|
|
||||||
|
def __init__(self, driver: RemoteWebDriver, timeout: float = ...) -> None:
|
||||||
|
self._driver: RemoteWebDriver = ...
|
||||||
|
self._url: str = ...
|
||||||
|
self._wait_object: WebDriverWait = ...
|
||||||
|
self._scroll: Scroll = ...
|
||||||
|
|
||||||
|
def __call__(self, loc_or_str: Union[Tuple[str, str], str, DriverElement, WebElement],
|
||||||
|
timeout: float = ...) -> Union[DriverElement, str, None]: ...
|
||||||
|
|
||||||
|
# -----------------共有属性和方法-------------------
|
||||||
|
@property
|
||||||
|
def url(self) -> Union[str, None]: ...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def html(self) -> str: ...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def json(self) -> dict: ...
|
||||||
|
|
||||||
|
def get(self,
|
||||||
|
url: str,
|
||||||
|
show_errmsg: bool = ...,
|
||||||
|
retry: int = ...,
|
||||||
|
interval: float = ...) -> Union[None, bool]: ...
|
||||||
|
|
||||||
|
def ele(self,
|
||||||
|
loc_or_ele: Union[Tuple[str, str], str, DriverElement, WebElement],
|
||||||
|
timeout: float = ...) -> Union[DriverElement, str, None]: ...
|
||||||
|
|
||||||
|
def eles(self,
|
||||||
|
loc_or_str: Union[Tuple[str, str], str],
|
||||||
|
timeout: float = ...) -> List[Union[DriverElement, str]]: ...
|
||||||
|
|
||||||
|
def s_ele(self, loc_or_ele: Union[Tuple[str, str], str, DriverElement] = ...) -> Union[
|
||||||
|
SessionElement, str, None]: ...
|
||||||
|
|
||||||
|
def s_eles(self, loc_or_str: Union[Tuple[str, str], str] = ...) -> List[Union[SessionElement, str]]: ...
|
||||||
|
|
||||||
|
def _ele(self,
|
||||||
|
loc_or_ele: Union[Tuple[str, str], str, DriverElement, WebElement],
|
||||||
|
timeout: float = ...,
|
||||||
|
single: bool = ...) -> Union[DriverElement, str, None, List[Union[DriverElement, str]]]: ...
|
||||||
|
|
||||||
|
def get_cookies(self, as_dict: bool = ...) -> Union[list, dict]: ...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def timeout(self) -> float: ...
|
||||||
|
|
||||||
|
@timeout.setter
|
||||||
|
def timeout(self, second: float) -> None: ...
|
||||||
|
|
||||||
|
def _d_connect(self,
|
||||||
|
to_url: str,
|
||||||
|
times: int = ...,
|
||||||
|
interval: float = ...,
|
||||||
|
show_errmsg: bool = ...) -> Union[bool, None]: ...
|
||||||
|
|
||||||
|
# ----------------driver独有属性和方法-----------------------
|
||||||
|
@property
|
||||||
|
def driver(self) -> WebDriver: ...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def wait_object(self) -> WebDriverWait: ...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def timeouts(self) -> dict: ...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def tabs_count(self) -> int: ...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def tab_handles(self) -> list: ...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def current_tab_index(self) -> int: ...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def current_tab_handle(self) -> str: ...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def active_ele(self) -> DriverElement: ...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def scroll(self) -> Scroll: ...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def to_frame(self) -> ToFrame: ...
|
||||||
|
|
||||||
|
def set_timeouts(self, implicit: float = ..., pageLoad: float = ..., script: float = ...) -> None: ...
|
||||||
|
|
||||||
|
def wait_ele(self,
|
||||||
|
loc_or_ele: Union[str, tuple, DriverElement, WebElement],
|
||||||
|
timeout: float = ...) -> ElementWaiter: ...
|
||||||
|
|
||||||
|
def check_page(self) -> Union[bool, None]: ...
|
||||||
|
|
||||||
|
def run_script(self, script: str, *args) -> Any: ...
|
||||||
|
|
||||||
|
def run_async_script(self, script: str, *args) -> Any: ...
|
||||||
|
|
||||||
|
def run_cdp(self, cmd: str, **cmd_args) -> Any: ...
|
||||||
|
|
||||||
|
def create_tab(self, url: str = ...) -> None: ...
|
||||||
|
|
||||||
|
def close_tabs(self, num_or_handles: Union[int, str, list, tuple] = ...) -> None: ...
|
||||||
|
|
||||||
|
def close_other_tabs(self, num_or_handles: Union[int, str, list, tuple] = ...) -> None: ...
|
||||||
|
|
||||||
|
def to_tab(self, num_or_handle: Union[int, str] = ...) -> None: ...
|
||||||
|
|
||||||
|
def set_ua_to_tab(self, ua: str) -> None: ...
|
||||||
|
|
||||||
|
def get_session_storage(self, item: str = ...) -> Union[str, dict, None]: ...
|
||||||
|
|
||||||
|
def get_local_storage(self, item: str = ...) -> Union[str, dict, None]: ...
|
||||||
|
|
||||||
|
def set_session_storage(self, item: str, value: Union[str, bool]) -> None: ...
|
||||||
|
|
||||||
|
def set_local_storage(self, item: str, value: Union[str, bool]) -> None: ...
|
||||||
|
|
||||||
|
def clean_cache(self,
|
||||||
|
session_storage: bool = ...,
|
||||||
|
local_storage: bool = ...,
|
||||||
|
cache: bool = ...,
|
||||||
|
cookies: bool = ...) -> None: ...
|
||||||
|
|
||||||
|
def screenshot(self, path: str = ..., filename: str = ..., as_bytes: bool = ...) -> Union[str, bytes]: ...
|
||||||
|
|
||||||
|
def scroll_to_see(self, loc_or_ele: Union[str, tuple, WebElement, DriverElement]) -> None: ...
|
||||||
|
|
||||||
|
def refresh(self) -> None: ...
|
||||||
|
|
||||||
|
def stop_loading(self) -> None: ...
|
||||||
|
|
||||||
|
def back(self) -> None: ...
|
||||||
|
|
||||||
|
def forward(self) -> None: ...
|
||||||
|
|
||||||
|
def set_window_size(self, width: int = ..., height: int = ...) -> None: ...
|
||||||
|
|
||||||
|
def chrome_downloading(self, download_path: str) -> list: ...
|
||||||
|
|
||||||
|
def process_alert(self, ok: bool = ..., send: str = ..., timeout: float = ...) -> Union[str, None]: ...
|
||||||
|
|
||||||
|
|
||||||
|
class ToFrame(object):
|
||||||
|
"""用于处理焦点跳转到页面框架的类"""
|
||||||
|
|
||||||
|
def __init__(self, page: DriverPage):
|
||||||
|
self.page: DriverPage = ...
|
||||||
|
|
||||||
|
def __call__(self, condition: Union[int, str, tuple, WebElement, DriverElement] = ...): ...
|
||||||
|
|
||||||
|
def main(self) -> DriverPage: ...
|
||||||
|
|
||||||
|
def parent(self, level: int = ...) -> DriverPage: ...
|
||||||
|
|
||||||
|
def by_id(self, id_: str) -> DriverPage: ...
|
||||||
|
|
||||||
|
def by_name(self, name: str) -> DriverPage: ...
|
||||||
|
|
||||||
|
def by_index(self, index: int) -> DriverPage: ...
|
||||||
|
|
||||||
|
def by_loc(self, loc: Union[str, tuple]) -> DriverPage: ...
|
||||||
|
|
||||||
|
def by_ele(self, ele: Union[DriverElement, WebElement]) -> DriverPage: ...
|
||||||
|
|
||||||
|
|
||||||
|
def _get_handles(handles: list, num_or_handles: Union[int, str, list, tuple]) -> set: ...
|
132
DrissionPage/mix_page.pyi
Normal file
132
DrissionPage/mix_page.pyi
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
# -*- coding:utf-8 -*-
|
||||||
|
from typing import Union, List, Tuple
|
||||||
|
|
||||||
|
from DownloadKit import DownloadKit
|
||||||
|
from requests import Response, Session
|
||||||
|
from requests.cookies import RequestsCookieJar
|
||||||
|
from selenium.webdriver.chrome.options import Options
|
||||||
|
from selenium.webdriver.chrome.webdriver import WebDriver
|
||||||
|
from selenium.webdriver.remote.webelement import WebElement
|
||||||
|
|
||||||
|
from .base import BasePage
|
||||||
|
from .config import DriverOptions, SessionOptions
|
||||||
|
from .drission import Drission
|
||||||
|
from .driver_element import DriverElement
|
||||||
|
from .driver_page import DriverPage
|
||||||
|
from .session_element import SessionElement
|
||||||
|
from .session_page import SessionPage
|
||||||
|
|
||||||
|
|
||||||
|
class MixPage(SessionPage, DriverPage, BasePage):
|
||||||
|
"""MixPage整合了DriverPage和SessionPage,封装了对页面的操作,
|
||||||
|
可在selenium(d模式)和requests(s模式)间无缝切换。
|
||||||
|
切换的时候会自动同步cookies。
|
||||||
|
获取信息功能为两种模式共有,操作页面元素功能只有d模式有。
|
||||||
|
调用某种模式独有的功能,会自动切换到该模式。
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self,
|
||||||
|
mode: str = ...,
|
||||||
|
drission: Union[Drission, str] = ...,
|
||||||
|
timeout: float = ...,
|
||||||
|
driver_options: Union[Options, DriverOptions, bool] = ...,
|
||||||
|
session_options: Union[dict, SessionOptions, bool] = ...) -> None:
|
||||||
|
self._mode: str = ...
|
||||||
|
self._drission: Drission = ...
|
||||||
|
|
||||||
|
def __call__(self,
|
||||||
|
loc_or_str: Union[Tuple[str, str], str, DriverElement, SessionElement, WebElement],
|
||||||
|
timeout: float = ...) -> Union[DriverElement, SessionElement, str, None]: ...
|
||||||
|
|
||||||
|
# -----------------共有属性和方法-------------------
|
||||||
|
@property
|
||||||
|
def url(self) -> Union[str, None]: ...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def title(self) -> str: ...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def html(self) -> str: ...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def json(self) -> dict: ...
|
||||||
|
|
||||||
|
def get(self,
|
||||||
|
url: str,
|
||||||
|
show_errmsg: bool = ...,
|
||||||
|
retry: int = ...,
|
||||||
|
interval: float = ...,
|
||||||
|
**kwargs) -> Union[bool, None]: ...
|
||||||
|
|
||||||
|
def ele(self,
|
||||||
|
loc_or_ele: Union[Tuple[str, str], str, DriverElement, SessionElement, WebElement],
|
||||||
|
timeout: float = ...) -> Union[DriverElement, SessionElement, str, None]: ...
|
||||||
|
|
||||||
|
def eles(self,
|
||||||
|
loc_or_str: Union[Tuple[str, str], str],
|
||||||
|
timeout: float = ...) -> List[Union[DriverElement, SessionElement, str]]: ...
|
||||||
|
|
||||||
|
def s_ele(self, loc_or_ele: Union[Tuple[str, str], str, DriverElement, SessionElement] = ...) \
|
||||||
|
-> Union[SessionElement, str, None]: ...
|
||||||
|
|
||||||
|
def s_eles(self, loc_or_str: Union[Tuple[str, str], str] = ...) -> List[Union[SessionElement, str]]: ...
|
||||||
|
|
||||||
|
def _ele(self,
|
||||||
|
loc_or_ele: Union[Tuple[str, str], str, DriverElement, SessionElement, WebElement],
|
||||||
|
timeout: float = ..., single: bool = ...) \
|
||||||
|
-> Union[DriverElement, SessionElement, str, None, List[Union[SessionElement, str]], List[
|
||||||
|
Union[DriverElement, str]]]: ...
|
||||||
|
|
||||||
|
def get_cookies(self, as_dict: bool = ..., all_domains: bool = ...) -> Union[dict, list]: ...
|
||||||
|
|
||||||
|
# ----------------MixPage独有属性和方法-----------------------
|
||||||
|
@property
|
||||||
|
def drission(self) -> Drission: ...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def driver(self) -> WebDriver: ...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def session(self) -> Session: ...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def response(self) -> Response: ...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def mode(self) -> str: ...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def _session_url(self) -> str: ...
|
||||||
|
|
||||||
|
def change_mode(self, mode: str = ..., go: bool = ..., copy_cookies: bool = ...) -> None: ...
|
||||||
|
|
||||||
|
def set_cookies(self, cookies: Union[RequestsCookieJar, list, tuple, str, dict], refresh: bool = ...) -> None: ...
|
||||||
|
|
||||||
|
def cookies_to_session(self, copy_user_agent: bool = ...) -> None: ...
|
||||||
|
|
||||||
|
def cookies_to_driver(self, url: str = ...) -> None: ...
|
||||||
|
|
||||||
|
def check_page(self, by_requests: bool = ...) -> Union[bool, None]: ...
|
||||||
|
|
||||||
|
def close_driver(self) -> None: ...
|
||||||
|
|
||||||
|
def close_session(self) -> None: ...
|
||||||
|
|
||||||
|
# ----------------重写SessionPage的函数-----------------------
|
||||||
|
def post(self,
|
||||||
|
url: str,
|
||||||
|
data: Union[dict, str] = ...,
|
||||||
|
show_errmsg: bool = ...,
|
||||||
|
retry: int = ...,
|
||||||
|
interval: float = ...,
|
||||||
|
**kwargs) -> bool: ...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def download(self) -> DownloadKit: ...
|
||||||
|
|
||||||
|
def chrome_downloading(self, path: str = ...) -> list: ...
|
||||||
|
|
||||||
|
# ----------------MixPage独有函数-----------------------
|
||||||
|
def hide_browser(self) -> None: ...
|
||||||
|
|
||||||
|
def show_browser(self) -> None: ...
|
@ -1,9 +1,4 @@
|
|||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
"""
|
|
||||||
@Author : g1879
|
|
||||||
@Contact : g1879@qq.com
|
|
||||||
@File : session_element.py
|
|
||||||
"""
|
|
||||||
from typing import Union, List, Tuple
|
from typing import Union, List, Tuple
|
||||||
|
|
||||||
from lxml.html import HtmlElement
|
from lxml.html import HtmlElement
|
||||||
@ -78,47 +73,37 @@ class SessionElement(DrissionElement):
|
|||||||
|
|
||||||
def befores(self,
|
def befores(self,
|
||||||
filter_loc: Union[tuple, str] = ...,
|
filter_loc: Union[tuple, str] = ...,
|
||||||
timeout: float = ...) -> List[Union['SessionElement', str]]:
|
timeout: float = ...) -> List[Union['SessionElement', str]]: ...
|
||||||
...
|
|
||||||
|
|
||||||
def afters(self,
|
def afters(self,
|
||||||
filter_loc: Union[tuple, str] = ...,
|
filter_loc: Union[tuple, str] = ...,
|
||||||
timeout: float = ...) -> List[Union['SessionElement', str]]:
|
timeout: float = ...) -> List[Union['SessionElement', str]]: ...
|
||||||
...
|
|
||||||
|
|
||||||
def attr(self, attr: str) -> Union[str, None]:
|
def attr(self, attr: str) -> Union[str, None]: ...
|
||||||
...
|
|
||||||
|
|
||||||
def ele(self,
|
def ele(self,
|
||||||
loc_or_str: Union[Tuple[str, str], str],
|
loc_or_str: Union[Tuple[str, str], str],
|
||||||
timeout: float = ...) -> Union['SessionElement', str, None]:
|
timeout: float = ...) -> Union['SessionElement', str, None]: ...
|
||||||
...
|
|
||||||
|
|
||||||
def eles(self,
|
def eles(self,
|
||||||
loc_or_str: Union[Tuple[str, str], str],
|
loc_or_str: Union[Tuple[str, str], str],
|
||||||
timeout: float = ...) -> List[Union['SessionElement', str]]:
|
timeout: float = ...) -> List[Union['SessionElement', str]]: ...
|
||||||
...
|
|
||||||
|
|
||||||
def s_ele(self,
|
def s_ele(self,
|
||||||
loc_or_str: Union[Tuple[str, str], str] = ...) -> Union['SessionElement', str, None]:
|
loc_or_str: Union[Tuple[str, str], str] = ...) -> Union['SessionElement', str, None]: ...
|
||||||
...
|
|
||||||
|
|
||||||
def s_eles(self,
|
def s_eles(self,
|
||||||
loc_or_str: Union[Tuple[str, str], str] = ...) -> List[Union['SessionElement', str]]:
|
loc_or_str: Union[Tuple[str, str], str] = ...) -> List[Union['SessionElement', str]]: ...
|
||||||
...
|
|
||||||
|
|
||||||
def _ele(self,
|
def _ele(self,
|
||||||
loc_or_str: Union[Tuple[str, str], str],
|
loc_or_str: Union[Tuple[str, str], str],
|
||||||
timeout: float = ...,
|
timeout: float = ...,
|
||||||
single: bool = ...,
|
single: bool = ...,
|
||||||
relative: bool = ...) -> Union['SessionElement', str, None, List[Union['SessionElement', str]]]:
|
relative: bool = ...) -> Union['SessionElement', str, None, List[Union['SessionElement', str]]]: ...
|
||||||
...
|
|
||||||
|
|
||||||
def _get_ele_path(self, mode: str) -> str:
|
def _get_ele_path(self, mode: str) -> str: ...
|
||||||
...
|
|
||||||
|
|
||||||
|
|
||||||
def make_session_ele(html_or_ele: Union[str, BaseElement, BasePage],
|
def make_session_ele(html_or_ele: Union[str, BaseElement, BasePage],
|
||||||
loc: Union[str, Tuple[str, str]] = ...,
|
loc: Union[str, Tuple[str, str]] = ...,
|
||||||
single: bool = ...) -> Union[SessionElement, str, None, List[Union[SessionElement, str]]]:
|
single: bool = ...) -> Union[SessionElement, str, None, List[Union[SessionElement, str]]]: ...
|
||||||
...
|
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
"""
|
|
||||||
@Author : g1879
|
|
||||||
@Contact : g1879@qq.com
|
|
||||||
@File : session_page.py
|
|
||||||
"""
|
|
||||||
from re import search
|
from re import search
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from typing import Union, List, Tuple
|
from typing import Union, List, Tuple
|
||||||
|
@ -4,11 +4,12 @@ from DownloadKit import DownloadKit
|
|||||||
from requests import Session, Response
|
from requests import Session, Response
|
||||||
from requests.cookies import RequestsCookieJar
|
from requests.cookies import RequestsCookieJar
|
||||||
|
|
||||||
|
from .base import BasePage
|
||||||
from .session_element import SessionElement
|
from .session_element import SessionElement
|
||||||
from .config import SessionOptions
|
from .config import SessionOptions
|
||||||
|
|
||||||
|
|
||||||
class SessionPage:
|
class SessionPage(BasePage):
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
session_or_options: Union[Session, SessionOptions] = ...,
|
session_or_options: Union[Session, SessionOptions] = ...,
|
||||||
timeout: float = ...):
|
timeout: float = ...):
|
||||||
@ -22,39 +23,26 @@ class SessionPage:
|
|||||||
self.retry_interval: float = ...
|
self.retry_interval: float = ...
|
||||||
|
|
||||||
def _create_session(self,
|
def _create_session(self,
|
||||||
Session_or_Options: Union[Session, SessionOptions]) -> None:
|
Session_or_Options: Union[Session, SessionOptions]) -> None: ...
|
||||||
...
|
|
||||||
|
|
||||||
def _set_session(self, data: dict) -> None:
|
def _set_session(self, data: dict) -> None: ...
|
||||||
...
|
|
||||||
|
|
||||||
def set_cookies(self, cookies: Union[RequestsCookieJar, list, tuple, str, dict]) -> None:
|
def set_cookies(self, cookies: Union[RequestsCookieJar, list, tuple, str, dict]) -> None: ...
|
||||||
...
|
|
||||||
|
|
||||||
def __call__(self,
|
def __call__(self,
|
||||||
loc_or_str: Union[Tuple[str, str], str, SessionElement],
|
loc_or_str: Union[Tuple[str, str], str, SessionElement],
|
||||||
timeout=...) -> Union[SessionElement, str, None]:
|
timeout=...) -> Union[SessionElement, str, None]: ...
|
||||||
"""在内部查找元素 \n
|
|
||||||
例:ele2 = ele1('@id=ele_id') \n
|
|
||||||
:param loc_or_str: 元素的定位信息,可以是loc元组,或查询字符串
|
|
||||||
:param timeout: 不起实际作用,用于和DriverElement对应,便于无差别调用
|
|
||||||
:return: SessionElement对象或属性文本
|
|
||||||
"""
|
|
||||||
return self.ele(loc_or_str)
|
|
||||||
|
|
||||||
# -----------------共有属性和方法-------------------
|
# -----------------共有属性和方法-------------------
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def url(self) -> str:
|
def url(self) -> str: ...
|
||||||
...
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def html(self) -> str:
|
def html(self) -> str: ...
|
||||||
...
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def json(self) -> dict:
|
def json(self) -> dict: ...
|
||||||
...
|
|
||||||
|
|
||||||
def get(self,
|
def get(self,
|
||||||
url: str,
|
url: str,
|
||||||
@ -64,73 +52,69 @@ class SessionPage:
|
|||||||
timeout: float | None = ...,
|
timeout: float | None = ...,
|
||||||
params: dict | None = ...,
|
params: dict | None = ...,
|
||||||
data: Union[dict, str, None] = ...,
|
data: Union[dict, str, None] = ...,
|
||||||
|
json: Union[dict, str, None] = ...,
|
||||||
headers: dict | None = ...,
|
headers: dict | None = ...,
|
||||||
cookies: Any | None = ...,
|
cookies: Any | None = ...,
|
||||||
files: Any | None = ...,
|
files: Any | None = ...,
|
||||||
auth: Any | None = ...,
|
auth: Any | None = ...,
|
||||||
allow_redirects: bool = ...,
|
allow_redirects: bool = ...,
|
||||||
proxies: Any | None = ...,
|
proxies: dict | None = ...,
|
||||||
hooks: Any | None = ...,
|
hooks: Any | None = ...,
|
||||||
stream: Any | None = ...,
|
stream: Any | None = ...,
|
||||||
verify: Any | None = ...,
|
verify: Any | None = ...,
|
||||||
cert: Any | None = ...,
|
cert: Any | None = ...) -> bool: ...
|
||||||
json: Union[dict, str, None] = ...,
|
|
||||||
) -> bool:
|
|
||||||
...
|
|
||||||
|
|
||||||
def ele(self,
|
def ele(self,
|
||||||
loc_or_ele: Union[Tuple[str, str], str, SessionElement],
|
loc_or_ele: Union[Tuple[str, str], str, SessionElement],
|
||||||
timeout: float = ...) -> Union[SessionElement, str, None]:
|
timeout: float = ...) -> Union[SessionElement, str, None]: ...
|
||||||
...
|
|
||||||
|
|
||||||
def eles(self,
|
def eles(self,
|
||||||
loc_or_str: Union[Tuple[str, str], str],
|
loc_or_str: Union[Tuple[str, str], str],
|
||||||
timeout: float = ...) -> List[Union[SessionElement, str]]:
|
timeout: float = ...) -> List[Union[SessionElement, str]]: ...
|
||||||
...
|
|
||||||
|
|
||||||
def s_ele(self,
|
def s_ele(self,
|
||||||
loc_or_ele: Union[Tuple[str, str], str, SessionElement] = ...) -> Union[SessionElement, str, None]:
|
loc_or_ele: Union[Tuple[str, str], str, SessionElement] = ...) -> Union[SessionElement, str, None]: ...
|
||||||
...
|
|
||||||
|
|
||||||
def s_eles(self, loc_or_str: Union[Tuple[str, str], str] = ...) -> List[Union[SessionElement, str]]:
|
def s_eles(self, loc_or_str: Union[Tuple[str, str], str] = ...) -> List[Union[SessionElement, str]]: ...
|
||||||
"""返回页面中符合条件的所有元素、属性或节点文本 \n
|
|
||||||
:param loc_or_str: 元素的定位信息,可以是元素对象,loc元组,或查询字符串
|
|
||||||
:return: SessionElement对象或属性、文本
|
|
||||||
"""
|
|
||||||
return self._ele(loc_or_str, single=False)
|
|
||||||
|
|
||||||
def _ele(self,
|
def _ele(self,
|
||||||
loc_or_ele: Union[Tuple[str, str], str, SessionElement],
|
loc_or_ele: Union[Tuple[str, str], str, SessionElement],
|
||||||
timeout: float = ...,
|
timeout: float = ...,
|
||||||
single: bool = ...) -> Union[SessionElement, str, None, List[Union[SessionElement, str]]]:
|
single: bool = ...) -> Union[SessionElement, str, None, List[Union[SessionElement, str]]]: ...
|
||||||
...
|
|
||||||
|
|
||||||
def get_cookies(self,
|
def get_cookies(self,
|
||||||
as_dict: bool = ...,
|
as_dict: bool = ...,
|
||||||
all_domains: bool = ...) -> Union[dict, list]:
|
all_domains: bool = ...) -> Union[dict, list]: ...
|
||||||
...
|
|
||||||
|
|
||||||
# ----------------session独有属性和方法-----------------------
|
# ----------------session独有属性和方法-----------------------
|
||||||
@property
|
@property
|
||||||
def session(self) -> Session:
|
def session(self) -> Session: ...
|
||||||
...
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def response(self) -> Response:
|
def response(self) -> Response: ...
|
||||||
...
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def download(self) -> DownloadKit:
|
def download(self) -> DownloadKit: ...
|
||||||
...
|
|
||||||
|
|
||||||
def post(self,
|
def post(self,
|
||||||
url: str,
|
url: str,
|
||||||
data: Union[dict, str] = ...,
|
show_errmsg: bool | None = ...,
|
||||||
show_errmsg: bool = ...,
|
retry: int | None = ...,
|
||||||
retry: int = ...,
|
interval: float | None = ...,
|
||||||
interval: float = ...,
|
timeout: float | None = ...,
|
||||||
**kwargs) -> bool:
|
params: dict | None = ...,
|
||||||
...
|
data: Union[dict, str, None] = ...,
|
||||||
|
json: Union[dict, str, None] = ...,
|
||||||
|
headers: dict | None = ...,
|
||||||
|
cookies: Any | None = ...,
|
||||||
|
files: Any | None = ...,
|
||||||
|
auth: Any | None = ...,
|
||||||
|
allow_redirects: bool = ...,
|
||||||
|
proxies: dict | None = ...,
|
||||||
|
hooks: Any | None = ...,
|
||||||
|
stream: Any | None = ...,
|
||||||
|
verify: Any | None = ...,
|
||||||
|
cert: Any | None = ..., ) -> bool: ...
|
||||||
|
|
||||||
def _s_connect(self,
|
def _s_connect(self,
|
||||||
url: str,
|
url: str,
|
||||||
@ -139,8 +123,7 @@ class SessionPage:
|
|||||||
show_errmsg: bool = ...,
|
show_errmsg: bool = ...,
|
||||||
retry: int = ...,
|
retry: int = ...,
|
||||||
interval: float = ...,
|
interval: float = ...,
|
||||||
**kwargs) -> bool:
|
**kwargs) -> bool: ...
|
||||||
...
|
|
||||||
|
|
||||||
def _make_response(self,
|
def _make_response(self,
|
||||||
url: str,
|
url: str,
|
||||||
@ -149,5 +132,4 @@ class SessionPage:
|
|||||||
retry: int = ...,
|
retry: int = ...,
|
||||||
interval: float = ...,
|
interval: float = ...,
|
||||||
show_errmsg: bool = ...,
|
show_errmsg: bool = ...,
|
||||||
**kwargs) -> tuple:
|
**kwargs) -> tuple: ...
|
||||||
...
|
|
||||||
|
80
DrissionPage/shadow_root_element.pyi
Normal file
80
DrissionPage/shadow_root_element.pyi
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
# -*- coding:utf-8 -*-
|
||||||
|
from typing import Union, Any, Tuple, List
|
||||||
|
|
||||||
|
from selenium.webdriver.remote.webelement import WebElement
|
||||||
|
|
||||||
|
from .driver_page import DriverPage
|
||||||
|
from .mix_page import MixPage
|
||||||
|
from .base import BaseElement
|
||||||
|
from .driver_element import DriverElement
|
||||||
|
from .session_element import SessionElement
|
||||||
|
|
||||||
|
|
||||||
|
class ShadowRootElement(BaseElement):
|
||||||
|
"""ShadowRootElement是用于处理ShadowRoot的类,使用方法和DriverElement基本一致"""
|
||||||
|
|
||||||
|
def __init__(self, inner_ele: WebElement, parent_ele: DriverElement):
|
||||||
|
self._inner_ele: WebElement = ...
|
||||||
|
self.parent_ele: DriverElement = ...
|
||||||
|
self.page: Union[MixPage, DriverPage] = ...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def inner_ele(self) -> WebElement: ...
|
||||||
|
|
||||||
|
def __repr__(self) -> str: ...
|
||||||
|
|
||||||
|
def __call__(self,
|
||||||
|
loc_or_str: Union[Tuple[str, str], str],
|
||||||
|
timeout: float = ...) -> Union[DriverElement, str, None]: ...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def tag(self) -> str: ...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def html(self) -> str: ...
|
||||||
|
|
||||||
|
@property
|
||||||
|
def inner_html(self) -> str: ...
|
||||||
|
|
||||||
|
def parent(self, level_or_loc: Union[str, int] = ...) -> DriverElement: ...
|
||||||
|
|
||||||
|
def next(self,
|
||||||
|
index: int = ...,
|
||||||
|
filter_loc: Union[tuple, str] = ...) -> Union[DriverElement, str, None]: ...
|
||||||
|
|
||||||
|
def before(self,
|
||||||
|
index: int = ...,
|
||||||
|
filter_loc: Union[tuple, str] = ...) -> Union[DriverElement, str, None]: ...
|
||||||
|
|
||||||
|
def after(self, index: int = ...,
|
||||||
|
filter_loc: Union[tuple, str] = ...) -> Union[DriverElement, str, None]: ...
|
||||||
|
|
||||||
|
def nexts(self, filter_loc: Union[tuple, str] = ...) -> List[Union[DriverElement, str]]: ...
|
||||||
|
|
||||||
|
def befores(self, filter_loc: Union[tuple, str] = ...) -> List[Union[DriverElement, str]]: ...
|
||||||
|
|
||||||
|
def afters(self, filter_loc: Union[tuple, str] = ...) -> List[Union[DriverElement, str]]: ...
|
||||||
|
|
||||||
|
def ele(self,
|
||||||
|
loc_or_str: Union[Tuple[str, str], str],
|
||||||
|
timeout: float = ...) -> Union[DriverElement, str, None]: ...
|
||||||
|
|
||||||
|
def eles(self,
|
||||||
|
loc_or_str: Union[Tuple[str, str], str],
|
||||||
|
timeout: float = ...) -> List[Union[DriverElement, str]]: ...
|
||||||
|
|
||||||
|
def s_ele(self, loc_or_ele=...) -> Union[SessionElement, str, None]: ...
|
||||||
|
|
||||||
|
def s_eles(self, loc_or_ele) -> List[Union[SessionElement, str]]: ...
|
||||||
|
|
||||||
|
def _ele(self,
|
||||||
|
loc_or_str: Union[Tuple[str, str], str],
|
||||||
|
timeout: float = ...,
|
||||||
|
single: bool = ...,
|
||||||
|
relative: bool = ...) -> Union[DriverElement, str, None, List[Union[DriverElement, str]]]: ...
|
||||||
|
|
||||||
|
def run_script(self, script: str, *args) -> Any: ...
|
||||||
|
|
||||||
|
def is_enabled(self) -> bool: ...
|
||||||
|
|
||||||
|
def is_valid(self) -> bool: ...
|
@ -1,16 +1,14 @@
|
|||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
from time import sleep
|
from typing import Union, Tuple, List, Any
|
||||||
from typing import Union, Tuple, List
|
|
||||||
|
|
||||||
from DownloadKit import DownloadKit
|
from DownloadKit import DownloadKit
|
||||||
from requests import Session, Response
|
from requests import Session, Response
|
||||||
from tldextract import extract
|
|
||||||
|
|
||||||
from .chromium_base import ChromiumBase, ChromiumFrame
|
|
||||||
from .base import BasePage
|
from .base import BasePage
|
||||||
from .chromium_element import ChromiumElement # , ChromiumBase
|
from .chromium_base import ChromiumFrame
|
||||||
|
from .chromium_element import ChromiumElement
|
||||||
from .chromium_page import ChromiumPage
|
from .chromium_page import ChromiumPage
|
||||||
from .config import DriverOptions, SessionOptions, _cookies_to_tuple
|
from .config import DriverOptions, SessionOptions
|
||||||
from .session_element import SessionElement
|
from .session_element import SessionElement
|
||||||
from .session_page import SessionPage
|
from .session_page import SessionPage
|
||||||
from .tab import Tab
|
from .tab import Tab
|
||||||
@ -24,7 +22,13 @@ class WebPage(SessionPage, ChromiumPage, BasePage):
|
|||||||
timeout: float = ...,
|
timeout: float = ...,
|
||||||
tab_id: str = ...,
|
tab_id: str = ...,
|
||||||
driver_or_options: Union[Tab, DriverOptions, bool] = ...,
|
driver_or_options: Union[Tab, DriverOptions, bool] = ...,
|
||||||
session_or_options: Union[Session, SessionOptions, bool] = ...) -> None: ...
|
session_or_options: Union[Session, SessionOptions, bool] = ...) -> None:
|
||||||
|
self._mode: str = ...
|
||||||
|
self._has_driver: bool = ...
|
||||||
|
self._has_session: bool = ...
|
||||||
|
self._session_options: dict = ...
|
||||||
|
self._driver_options: DriverOptions = ...
|
||||||
|
self._setting_tab_id: str = ...
|
||||||
|
|
||||||
def __call__(self,
|
def __call__(self,
|
||||||
loc_or_str: Union[Tuple[str, str], str, ChromiumElement, SessionElement],
|
loc_or_str: Union[Tuple[str, str], str, ChromiumElement, SessionElement],
|
||||||
@ -61,19 +65,31 @@ class WebPage(SessionPage, ChromiumPage, BasePage):
|
|||||||
@property
|
@property
|
||||||
def _driver(self) -> Tab: ...
|
def _driver(self) -> Tab: ...
|
||||||
|
|
||||||
@_driver.setter
|
# @_driver.setter
|
||||||
def _driver(self, tab): ...
|
# def _driver(self, tab): ...
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _session_url(self) -> str: ...
|
def _session_url(self) -> str: ...
|
||||||
|
|
||||||
def get(self,
|
def get(self,
|
||||||
url: str,
|
url: str,
|
||||||
show_errmsg: bool = ...,
|
show_errmsg: bool | None = ...,
|
||||||
retry: int = ...,
|
retry: int | None = ...,
|
||||||
interval: float = ...,
|
interval: float | None = ...,
|
||||||
timeout: float = ...,
|
timeout: float | None = ...,
|
||||||
**kwargs) -> Union[bool, None]: ...
|
params: dict | None = ...,
|
||||||
|
data: Union[dict, str, None] = ...,
|
||||||
|
json: Union[dict, str, None] = ...,
|
||||||
|
headers: dict | None = ...,
|
||||||
|
cookies: Any | None = ...,
|
||||||
|
files: Any | None = ...,
|
||||||
|
auth: Any | None = ...,
|
||||||
|
allow_redirects: bool = ...,
|
||||||
|
proxies: dict | None = ...,
|
||||||
|
hooks: Any | None = ...,
|
||||||
|
stream: Any | None = ...,
|
||||||
|
verify: Any | None = ...,
|
||||||
|
cert: Any | None = ...) -> Union[bool, None]: ...
|
||||||
|
|
||||||
def ele(self,
|
def ele(self,
|
||||||
loc_or_ele: Union[Tuple[str, str], str, ChromiumElement, SessionElement],
|
loc_or_ele: Union[Tuple[str, str], str, ChromiumElement, SessionElement],
|
||||||
@ -109,11 +125,23 @@ class WebPage(SessionPage, ChromiumPage, BasePage):
|
|||||||
# ----------------重写SessionPage的函数-----------------------
|
# ----------------重写SessionPage的函数-----------------------
|
||||||
def post(self,
|
def post(self,
|
||||||
url: str,
|
url: str,
|
||||||
data: Union[dict, str] = ...,
|
show_errmsg: bool | None = ...,
|
||||||
show_errmsg: bool = ...,
|
retry: int | None = ...,
|
||||||
retry: int = ...,
|
interval: float | None = ...,
|
||||||
interval: float = ...,
|
timeout: float | None = ...,
|
||||||
**kwargs) -> bool: ...
|
params: dict | None = ...,
|
||||||
|
data: Union[dict, str, None] = ...,
|
||||||
|
json: Union[dict, str, None] = ...,
|
||||||
|
headers: dict | None = ...,
|
||||||
|
cookies: Any | None = ...,
|
||||||
|
files: Any | None = ...,
|
||||||
|
auth: Any | None = ...,
|
||||||
|
allow_redirects: bool = ...,
|
||||||
|
proxies: dict | None = ...,
|
||||||
|
hooks: Any | None = ...,
|
||||||
|
stream: Any | None = ...,
|
||||||
|
verify: Any | None = ...,
|
||||||
|
cert: Any | None = ...) -> bool: ...
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def download(self) -> DownloadKit: ...
|
def download(self) -> DownloadKit: ...
|
||||||
|
Loading…
x
Reference in New Issue
Block a user