微调,修复小问题

This commit is contained in:
g1879 2023-12-12 17:09:17 +08:00
parent cea156fc86
commit a11267c8a3
5 changed files with 25 additions and 21 deletions

View File

@ -124,16 +124,6 @@ class ChromiumOptions(object):
"""返回代理设置"""
return self._proxy
@property
def debugger_address(self):
"""返回浏览器地址ip:port"""
return self._address
@debugger_address.setter
def debugger_address(self, address):
"""设置浏览器地址格式ip:port"""
self.set_address(address)
@property
def address(self):
"""返回浏览器地址ip:port"""
@ -278,7 +268,7 @@ class ChromiumOptions(object):
return self
def clear_flags_in_file(self):
"""删除浏览器置文件中已设置的实验项"""
"""删除浏览器置文件中已设置的实验项"""
self.clear_file_flags = True
return self
@ -370,7 +360,7 @@ class ChromiumOptions(object):
"""
if search(r'.*?:.*?@.*?\..*', proxy):
print('你似乎在设置使用账号密码的代理,暂时不支持这种代理,可自行用插件实现需求。')
if not proxy.lower().startswith('socks'):
if proxy.lower().startswith('socks'):
print('你似乎在设置使用socks代理暂时不支持这种代理可自行用插件实现需求。')
self._proxy = proxy
return self.set_argument('--proxy-server', proxy)
@ -558,6 +548,16 @@ class ChromiumOptions(object):
# ---------------即将废弃--------------
@property
def debugger_address(self):
"""返回浏览器地址ip:port"""
return self._address
@debugger_address.setter
def debugger_address(self, address):
"""设置浏览器地址格式ip:port"""
self.set_address(address)
def set_page_load_strategy(self, value):
return self.set_load_mode(value)

View File

@ -4,7 +4,7 @@
@Contact : g1879@qq.com
"""
from pathlib import Path
from typing import Union, Tuple, Any
from typing import Union, Tuple, Any, Literal
class ChromiumOptions(object):
@ -121,7 +121,7 @@ class ChromiumOptions(object):
def ignore_certificate_errors(self, on_off=True) -> ChromiumOptions: ...
def set_load_mode(self, value: str) -> ChromiumOptions: ...
def set_load_mode(self, value: Literal['normal', 'eager', 'none']) -> ChromiumOptions: ...
def set_browser_path(self, path: Union[str, Path]) -> ChromiumOptions: ...

View File

@ -89,7 +89,7 @@ class SessionOptions(object):
"""返回默认下载路径属性信息"""
return self._download_path
def set_download_path(self, path=None):
def set_download_path(self, path):
"""设置默认下载路径
:param path: 下载路径
:return: 返回当前对象

View File

@ -232,7 +232,7 @@ def stop_process_on_port(port):
for proc in process_iter(['pid', 'connections']):
try:
connections = proc.connections()
except AccessDenied:
except (AccessDenied, NoSuchProcess):
continue
for conn in connections:
if conn.laddr.port == int(port):

View File

@ -9,8 +9,8 @@ from .._base.chromium_driver import ChromiumDriver
from .._elements.chromium_element import ChromiumElement
from .._pages.chromium_base import ChromiumBase
KEYS = Literal['NULL', 'CANCEL', 'HELP', 'BACKSPACE', 'BACK_SPACE',
'TAB', 'CLEAR', 'RETURN', 'ENTER', 'SHIFT', 'LEFT_SHIFT', 'CONTROL',
KEYS = Literal['NULL', 'CANCEL', 'HELP', 'BACKSPACE', 'BACK_SPACE', 'meta',
'TAB', 'CLEAR', 'RETURN', 'ENTER', 'SHIFT', 'LEFT_SHIFT', 'CONTROL', 'command ',
'CTRL', 'LEFT_CONTROL', 'ALT', 'LEFT_ALT', 'PAUSE', 'ESCAPE', 'SPACE',
'PAGE_UP', 'PAGE_DOWN', 'END', 'HOME', 'LEFT', 'ARROW_LEFT', 'UP',
'ARROW_UP', 'RIGHT', 'ARROW_RIGHT', 'DOWN', 'ARROW_DOWN', 'INSERT',
@ -25,14 +25,18 @@ KEYS = Literal['NULL', 'CANCEL', 'HELP', 'BACKSPACE', 'BACK_SPACE',
'semicolon', 'equals', 'numpad0', 'numpad1', 'numpad2', 'numpad3', 'numpad4', 'numpad5',
'numpad6', 'numpad7', 'numpad8', 'numpad9', 'multiply', 'add', 'subtract', 'decimal',
'divide', 'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'f10', 'f11', 'f12',
'meta', 'command ',
'\ue000', '\ue002', '\ue003', '\ue004', '\ue005', '\ue006', '\ue007', '\ue008', '\ue009',
'\ue009', '\ue00a', '\ue00b', '\ue00c', '\ue00d', '\ue00e', '\ue00f', '\ue010', '\ue011',
'\ue012', '\ue013', '\ue014', '\ue015', '\ue016', '\ue017', '\ue017', '\ue018', '\ue019',
'\ue01a', '\ue01b', '\ue01c', '\ue01d', '\ue01e', '\ue01f', '\ue020', '\ue021', '\ue022',
'\ue023', '\ue024', '\ue025', '\ue027', '\ue028', '\ue029', '\ue031', '\ue032', '\ue033', '\ue034',
'\ue035', '\ue036', '\ue037', '\ue038', '\ue039', '\ue03a', '\ue03b', '\ue03c', '\ue03d', '\ue03d'
]
'\ue035', '\ue036', '\ue037', '\ue038', '\ue039', '\ue03a', '\ue03b', '\ue03c', '\ue03d', '\ue03d',
'`', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 'q', 'w',
'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\\', 'a', 's', 'd', 'f',
'g', 'h', 'j', 'k', 'l', ';', '\'', 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',',
'.', '/', '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+',
'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', 'A', 'S', 'D',
'F', 'G', 'H', 'J', 'K', 'L', ':', '"', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?']
class Actions: