diff --git a/DrissionPage/_configs/chromium_options.py b/DrissionPage/_configs/chromium_options.py index d483967..0a5a9e7 100644 --- a/DrissionPage/_configs/chromium_options.py +++ b/DrissionPage/_configs/chromium_options.py @@ -532,9 +532,9 @@ class ChromiumOptions(object): path = path / 'config.ini' if path.is_dir() else path if path.exists(): - om = OptionsManager(str(path)) + om = OptionsManager(path) else: - om = OptionsManager(self.ini_path or str(Path(__file__).parent / 'configs.ini')) + om = OptionsManager(self.ini_path or (Path(__file__).parent / 'configs.ini')) # 设置chromium_options attrs = ('address', 'browser_path', 'arguments', 'extensions', 'user', 'load_mode', diff --git a/DrissionPage/_configs/options_manage.py b/DrissionPage/_configs/options_manage.py index e6867e3..f9c85f4 100644 --- a/DrissionPage/_configs/options_manage.py +++ b/DrissionPage/_configs/options_manage.py @@ -29,6 +29,8 @@ class OptionsManager(object): self.ini_path = default_configs elif path == 'default': self.ini_path = default_configs + elif isinstance(path, Path): + self.ini_path = path else: self.ini_path = Path(path) @@ -147,6 +149,7 @@ class OptionsManager(object): path = Path(path).absolute() path = path / 'config.ini' if path.is_dir() else path + path.parent.mkdir(exist_ok=True, parents=True) path = str(path) self._conf.write(open(path, 'w', encoding='utf-8')) diff --git a/DrissionPage/_configs/options_manage.pyi b/DrissionPage/_configs/options_manage.pyi index 80e438d..f2b0483 100644 --- a/DrissionPage/_configs/options_manage.pyi +++ b/DrissionPage/_configs/options_manage.pyi @@ -7,7 +7,7 @@ """ from configparser import RawConfigParser from pathlib import Path -from typing import Any, Optional +from typing import Any, Optional, Union class OptionsManager(object): @@ -15,7 +15,7 @@ class OptionsManager(object): file_exists: bool = ... _conf: RawConfigParser = ... - def __init__(self, path: str = None): ... + def __init__(self, path: Union[Path, str] = None): ... def __getattr__(self, item) -> dict: ... diff --git a/DrissionPage/_configs/session_options.py b/DrissionPage/_configs/session_options.py index 6373441..a3318ed 100644 --- a/DrissionPage/_configs/session_options.py +++ b/DrissionPage/_configs/session_options.py @@ -377,9 +377,9 @@ class SessionOptions(object): path = path / 'config.ini' if path.is_dir() else path if path.exists(): - om = OptionsManager(str(path)) + om = OptionsManager(path) else: - om = OptionsManager(self.ini_path or str(Path(__file__).parent / 'configs.ini')) + om = OptionsManager(self.ini_path or (Path(__file__).parent / 'configs.ini')) options = session_options_to_dict(self) diff --git a/DrissionPage/_pages/chromium_base.py b/DrissionPage/_pages/chromium_base.py index 92cb9a7..45225f1 100644 --- a/DrissionPage/_pages/chromium_base.py +++ b/DrissionPage/_pages/chromium_base.py @@ -1064,7 +1064,11 @@ class ChromiumBase(BasePage): vp = {'x': 0, 'y': 0, 'width': width, 'height': height, 'scale': 1} args = {'format': pic_type, 'captureBeyondViewport': True, 'clip': vp} else: - if left_top and right_bottom: + if left_top or right_bottom: + if not left_top: + left_top = (0, 0) + if not right_bottom: + right_bottom = self.rect.size x, y = left_top w = right_bottom[0] - x h = right_bottom[1] - y