完善设置功能,待测试

This commit is contained in:
g1879 2022-01-11 23:00:41 +08:00
parent c68fd34c6b
commit d1831de7a1
2 changed files with 11 additions and 15 deletions

View File

@ -31,12 +31,6 @@ class OptionsManager(object):
self._chrome_options = None
self._session_options = None
# if 'tmp_path' not in self.paths or not self.get_value('paths', 'tmp_path'):
# tmp_path = str((Path(__file__).parent / 'tmp').absolute())
# Path(tmp_path).mkdir(parents=True, exist_ok=True)
# self.set_item('paths', 'tmp_path', tmp_path)
# self.save(self.ini_path)
def __text__(self) -> str:
"""打印ini文件内容"""
return (f"paths:\n"
@ -93,7 +87,7 @@ class OptionsManager(object):
for j in items:
try:
option[j[0]] = eval(self._conf.get(section, j[0]).replace('\\', '\\\\'))
option[j[0]] = eval(self._conf.get(section, j[0]))
except Exception:
option[j[0]] = self._conf.get(section, j[0])
@ -470,7 +464,9 @@ class DriverOptions(Options):
self._driver_path = om.paths.get('chromedriver_path', None)
self.set_window_rect = options_dict.get('set_window_rect', None)
self.page_load_strategy = om.paths.get('page_load_strategy', 'normal')
self.timeouts = options_dict.get('timeouts', {'implicit': 10, 'pageLoad': 10, 'script': 10})
self.timeouts = options_dict.get('timeouts', {'implicit': 10, 'pageLoad': 30, 'script': 30})
self.timeouts['pageLoad'] *= 1000
self.timeouts['script'] *= 1000
@property
def driver_path(self) -> str:

View File

@ -1,6 +1,6 @@
[paths]
chromedriver_path =
tmp_path =
tmp_path =
[chrome_options]
debugger_address = 127.0.0.1:9222
@ -8,15 +8,15 @@ binary_location =
arguments = ['--no-sandbox', '--disable-gpu', '--ignore-certificate-errors', '--disable-infobars']
extensions = []
experimental_options = {'prefs': {'profile.default_content_settings.popups': 0, 'profile.default_content_setting_values': {'notifications': 2}, 'plugins.plugins_list': [{'enabled': False, 'name': 'Chrome PDF Viewer'}]}, 'useAutomationExtension': False, 'excludeSwitches': ['enable-automation']}
timeouts = {'implicit': 10, 'pageLoad': 50, 'script': 50}
timeouts = {'implicit': 10, 'pageLoad': 30, 'script': 30}
set_window_rect = None
page_load_strategy = normal
[session_options]
headers = {
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Connection": "keep-alive",
"Accept-Charset": "GB2312,utf-8;q=0.7,*;q=0.7"
}
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Connection": "keep-alive",
"Accept-Charset": "GB2312,utf-8;q=0.7,*;q=0.7"
}