修改注释

This commit is contained in:
g1879 2020-06-05 18:34:54 +08:00
parent a4f662333d
commit d2d6b4a200

View File

@ -14,7 +14,7 @@ def set_paths(driver_path: str = None,
debugger_address: str = None,
tmp_path: str = None,
download_path: str = None,
uesr_data_path: str = None,
user_data_path: str = None,
cache_path: str = None,
check_version: bool = True) -> None:
"""简易设置路径函数
@ -23,7 +23,7 @@ def set_paths(driver_path: str = None,
:param debugger_address: 调试浏览器地址127.0.0.1:9222
:param download_path: 下载文件路径
:param tmp_path: 临时文件夹路径
:param uesr_data_path: 用户数据路径
:param user_data_path: 用户数据路径
:param cache_path: 缓存路径
:param check_version: 是否检查chromedriver和chrome是否匹配
:return: None
@ -42,8 +42,8 @@ def set_paths(driver_path: str = None,
experimental_options['prefs']['download.default_directory'] = download_path
om.set_item('chrome_options', 'experimental_options', experimental_options)
om.save()
if uesr_data_path is not None:
set_value_argument('--user-data-dir', uesr_data_path)
if user_data_path is not None:
set_value_argument('--user-data-dir', user_data_path)
if cache_path is not None:
set_value_argument('--disk-cache-dir', cache_path)
if check_version:
@ -51,7 +51,7 @@ def set_paths(driver_path: str = None,
def set_value_argument(arg: str, value: str) -> None:
"""设置代理"""
"""设置有值的属性"""
do = DriverOptions()
pr_ok = False
for key, argument in enumerate(do.arguments):
@ -70,7 +70,7 @@ def set_value_argument(arg: str, value: str) -> None:
def set_argument(arg: str, on_off: bool) -> None:
"""设置argument"""
"""设置没有值的属性"""
do = DriverOptions()
if on_off:
if arg not in do.arguments:
@ -80,18 +80,13 @@ def set_argument(arg: str, on_off: bool) -> None:
do.save()
def set_proxy(proxy: str) -> None:
"""设置代理"""
set_value_argument('--proxy-server', proxy)
def set_headless(on_off: bool = True) -> None:
"""设置headless"""
set_argument('--headless', on_off)
def set_no_imgs(on_off: bool = True) -> None:
"""设置headless"""
"""设置是否加载图片"""
set_argument('--blink-settings=imagesEnabled=false', on_off)
@ -106,9 +101,15 @@ def set_mute(on_off: bool = True) -> None:
def set_user_agent(user_agent: str) -> None:
"""设置user agent"""
set_value_argument('user-agent', user_agent)
def set_proxy(proxy: str) -> None:
"""设置代理"""
set_value_argument('--proxy-server', proxy)
def check_driver_version(driver_path: str = None, chrome_path: str = None) -> bool:
"""检查传入的chrome和chromedriver是否匹配"""
print('正在检测可用性...')