From a877f646e0a959fe2f79c0e0637e2ebec4fab288 Mon Sep 17 00:00:00 2001 From: g1879 Date: Fri, 28 Jun 2024 23:54:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=8E=B7=E5=8F=96link?= =?UTF-8?q?=E6=97=B6./=E5=BC=80=E5=A4=B4=E9=93=BE=E6=8E=A5=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/_functions/web.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/DrissionPage/_functions/web.py b/DrissionPage/_functions/web.py index 461f143..a9ee8e5 100644 --- a/DrissionPage/_functions/web.py +++ b/DrissionPage/_functions/web.py @@ -10,7 +10,7 @@ from html import unescape from http.cookiejar import Cookie, CookieJar from os.path import sep from pathlib import Path -from re import sub, match +from re import sub from urllib.parse import urlparse, urljoin, urlunparse from DataRecorder.tools import make_valid_name @@ -144,8 +144,11 @@ def make_absolute_link(link, baseURI=None): link = link.strip().replace('\\', '/') parsed = urlparse(link)._asdict() if baseURI: - p = urlparse(baseURI)._asdict() - baseURI = f'{p["scheme"]}://{p["netloc"]}' + if link.startswith('./'): + baseURI = baseURI[:baseURI.rfind('/') + 1] + else: + p = urlparse(baseURI)._asdict() + baseURI = f'{p["scheme"]}://{p["netloc"]}' # 是相对路径,与页面url拼接并返回 if not parsed['netloc']: