获取url中 域名等信息
urllib是内置模块
from urllib.parse import urlparse
url='http://www.leontom.cc/post/719.html'
res=urlparse(url)
print("返回对象:", res)
print("域名", res.netloc)
----------打印结果----------------
#返回对象: ParseResult(scheme='http', netloc='www.leontom.cc', path='/post/719.html', # params='', query='', fragment='')
#域名: www.leontom.cc