mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
增加click.to_download();修复body注释报错问题
This commit is contained in:
parent
03378136c4
commit
043b33f16e
@ -140,6 +140,27 @@ class Clicker(object):
|
||||
"""
|
||||
self.at(count=times)
|
||||
|
||||
def to_download(self, save_path=None, rename=None, suffix=None, new_tab=False):
|
||||
"""点击触发下载
|
||||
:param save_path: 保存路径,为None保存在原来设置的,如未设置保存到当前路径
|
||||
:param rename: 重命名文件名
|
||||
:param suffix: 指定文件后缀
|
||||
:param new_tab: 是否在新tab触发下载
|
||||
:return: DownloadMission对象
|
||||
"""
|
||||
if save_path:
|
||||
self._ele.page.set.download_path(save_path)
|
||||
elif not self._ele.page._page._browser._dl_mgr._running:
|
||||
self._ele.page.set.download_path('.')
|
||||
|
||||
if rename or suffix:
|
||||
self._ele.page.set.download_file_name(rename, suffix)
|
||||
|
||||
tab = self._ele.page._page if new_tab else self._ele.page
|
||||
|
||||
self._ele.click()
|
||||
return tab.wait.download_begin()
|
||||
|
||||
def _click(self, client_x, client_y, button='left', count=1):
|
||||
"""实施点击
|
||||
:param client_x: 视口中的x坐标
|
||||
|
@ -5,8 +5,10 @@
|
||||
@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved.
|
||||
@License : BSD 3-Clause.
|
||||
"""
|
||||
from typing import Optional
|
||||
from pathlib import Path
|
||||
from typing import Optional, Union
|
||||
|
||||
from .downloader import DownloadMission
|
||||
from .._elements.chromium_element import ChromiumElement
|
||||
|
||||
|
||||
@ -14,16 +16,26 @@ class Clicker(object):
|
||||
def __init__(self, ele: ChromiumElement):
|
||||
self._ele: ChromiumElement = ...
|
||||
|
||||
def __call__(self, by_js: Optional[bool] = False, timeout: float = 1.5, wait_stop: bool = True) -> bool: ...
|
||||
def __call__(self, by_js: Optional[bool, str] = False, timeout: float = 1.5, wait_stop: bool = True) -> bool: ...
|
||||
|
||||
def left(self, by_js: Optional[bool] = False, timeout: float = 1.5, wait_stop: bool = True) -> bool: ...
|
||||
def left(self, by_js: Optional[bool, str] = False, timeout: float = 1.5, wait_stop: bool = True) -> bool: ...
|
||||
|
||||
def right(self) -> None: ...
|
||||
|
||||
def middle(self) -> None: ...
|
||||
|
||||
def at(self, offset_x: float = None, offset_y: float = None, button: str = 'left', count: int = 1) -> None: ...
|
||||
def at(self,
|
||||
offset_x: float = None,
|
||||
offset_y: float = None,
|
||||
button: str = 'left',
|
||||
count: int = 1) -> None: ...
|
||||
|
||||
def multi(self, times: int = 2) -> None: ...
|
||||
|
||||
def to_download(self,
|
||||
save_path: Union[str, Path] = None,
|
||||
rename: str = None,
|
||||
suffix: str = None,
|
||||
new_tab: bool = False) -> DownloadMission: ...
|
||||
|
||||
def _click(self, client_x: float, client_y: float, button: str = 'left', count: int = 1) -> None: ...
|
||||
|
@ -23,7 +23,7 @@ class Listener(object):
|
||||
self._page: ChromiumBase = ...
|
||||
self._address: str = ...
|
||||
self._target_id: str = ...
|
||||
self._targets: Union[str, dict] = ...
|
||||
self._targets: Optional[str, dict] = ...
|
||||
self._method: set = ...
|
||||
self._res_type: set = ...
|
||||
self._caught: Queue = ...
|
||||
@ -172,7 +172,7 @@ class Request(object):
|
||||
def headers(self) -> dict: ...
|
||||
|
||||
@property
|
||||
def postData(self) -> Union[str, dict]: ...
|
||||
def postData(self) -> Optional[str, dict]: ...
|
||||
|
||||
@property
|
||||
def extra_info(self) -> Optional[RequestExtraInfo]: ...
|
||||
@ -208,7 +208,7 @@ class Response(object):
|
||||
self._response: dict = ...
|
||||
self._raw_body: str = ...
|
||||
self._is_base64_body: bool = ...
|
||||
self._body: Union[str, dict] = ...
|
||||
self._body: Optional[str, dict] = ...
|
||||
self._headers: dict = ...
|
||||
|
||||
@property
|
||||
@ -221,7 +221,7 @@ class Response(object):
|
||||
def raw_body(self) -> str: ...
|
||||
|
||||
@property
|
||||
def body(self) -> Union[str, dict]: ...
|
||||
def body(self) -> Optional[str, dict]: ...
|
||||
|
||||
|
||||
class ExtraInfo(object):
|
||||
|
Loading…
x
Reference in New Issue
Block a user