mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
修复获取绝对路径的小问题
This commit is contained in:
parent
7b03820fa6
commit
c417555ebf
@ -279,12 +279,12 @@ class SessionElement(DrissionElement):
|
|||||||
|
|
||||||
parsed = urlparse(link)._asdict()
|
parsed = urlparse(link)._asdict()
|
||||||
|
|
||||||
# 相对路径,与页面url拼接并返回
|
# 是相对路径,与页面url拼接并返回
|
||||||
if not parsed['netloc']: # 相对路径,与
|
if not parsed['netloc']:
|
||||||
return urljoin(self.page.url, link)
|
return urljoin(self.page.url, link) if self.page else link
|
||||||
|
|
||||||
# 绝对路径但缺少协议,从页面url获取协议并修复
|
# 是绝对路径但缺少协议,从页面url获取协议并修复
|
||||||
if not parsed['scheme']:
|
if not parsed['scheme'] and self.page:
|
||||||
parsed['scheme'] = urlparse(self.page.url).scheme
|
parsed['scheme'] = urlparse(self.page.url).scheme
|
||||||
parsed = tuple(v for v in parsed.values())
|
parsed = tuple(v for v in parsed.values())
|
||||||
return urlunparse(parsed)
|
return urlunparse(parsed)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user