From c417555ebfe27c8ba30c136c8414840ed370e8a0 Mon Sep 17 00:00:00 2001 From: g1879 Date: Tue, 1 Mar 2022 17:56:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=8E=B7=E5=8F=96=E7=BB=9D?= =?UTF-8?q?=E5=AF=B9=E8=B7=AF=E5=BE=84=E7=9A=84=E5=B0=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/session_element.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/DrissionPage/session_element.py b/DrissionPage/session_element.py index e383591..6b329b8 100644 --- a/DrissionPage/session_element.py +++ b/DrissionPage/session_element.py @@ -279,12 +279,12 @@ class SessionElement(DrissionElement): parsed = urlparse(link)._asdict() - # 相对路径,与页面url拼接并返回 - if not parsed['netloc']: # 相对路径,与 - return urljoin(self.page.url, link) + # 是相对路径,与页面url拼接并返回 + if not parsed['netloc']: + return urljoin(self.page.url, link) if self.page else link - # 绝对路径但缺少协议,从页面url获取协议并修复 - if not parsed['scheme']: + # 是绝对路径但缺少协议,从页面url获取协议并修复 + if not parsed['scheme'] and self.page: parsed['scheme'] = urlparse(self.page.url).scheme parsed = tuple(v for v in parsed.values()) return urlunparse(parsed)