From 1be8f00c2183afeb309e53c01c0b15547f2b8918 Mon Sep 17 00:00:00 2001 From: g1879 Date: Wed, 3 Jan 2024 17:40:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E8=B0=83get()=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=9B=E4=B8=8D=E6=8C=87=E5=AE=9A=E7=94=A8=E6=88=B7=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=A4=B9=E8=B7=AF=E5=BE=84=E6=97=B6=E4=BC=98=E5=85=88?= =?UTF-8?q?=E9=80=89=E6=8B=A9tmp=5Fpath?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/_functions/browser.py | 3 ++- DrissionPage/_pages/chromium_base.py | 10 ++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/DrissionPage/_functions/browser.py b/DrissionPage/_functions/browser.py index 33f0df6..99e1211 100644 --- a/DrissionPage/_functions/browser.py +++ b/DrissionPage/_functions/browser.py @@ -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}') diff --git a/DrissionPage/_pages/chromium_base.py b/DrissionPage/_pages/chromium_base.py index 87d0c70..3b66a76 100644 --- a/DrissionPage/_pages/chromium_base.py +++ b/DrissionPage/_pages/chromium_base.py @@ -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