📜  python urlparse 获取域 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:43.781000             🧑  作者: Mango

代码示例1
from urllib.parse import urlparse

domain = urlparse('http://www.example.test/foo/bar').netloc
print(domain) # --> www.example.test

#To get without the subdomain
t = urlparse('http://abc.hostname.com/somethings/anything/').netloc
print ('.'.join(t.split('.')[1:])) # --> hostname.com