微调get()逻辑;不指定用户文件夹路径时优先选择tmp_path

This commit is contained in:
g1879 2024-01-03 17:40:35 +08:00
parent 5c8ba2da58
commit 1be8f00c21
2 changed files with 4 additions and 9 deletions

View File

@ -87,7 +87,8 @@ def get_launch_args(opt):
if not has_user_path and not opt.system_user_path:
port = opt.address.split(':')[-1] if opt.address else '0'
path = Path(gettempdir()) / 'DrissionPage' / f'userData_{port}'
p = Path(opt.tmp_path) if opt.tmp_path else Path(gettempdir()) / 'DrissionPage'
path = p / f'userData_{port}'
path.mkdir(parents=True, exist_ok=True)
opt.set_user_data_path(path)
result.add(f'--user-data-dir={path}')

View File

@ -6,7 +6,7 @@
from json import loads, JSONDecodeError
from os.path import sep
from pathlib import Path
from re import findall, match
from re import findall
from threading import Thread
from time import perf_counter, sleep
from urllib.parse import quote
@ -894,13 +894,7 @@ class ChromiumBase(BasePage):
:param interval: 重试间隔
:return: 重试次数和间隔组成的tuple
"""
url = quote(url, safe='-_.~!*\'"();:@&=+$,/\\?#[]%')
if not url:
self._url = 'chrome://newtab/'
elif not match(r'.*?://', url):
self._url = f'http://{url}'
else:
self._url = url
self._url = quote(url, safe='-_.~!*\'"();:@&=+$,/\\?#[]%') or 'chrome://newtab/'
retry = retry if retry is not None else self.retry_times
interval = interval if interval is not None else self.retry_interval
return retry, interval