安装依赖:
- pip install tldextract==2.2.2
# url = "https://zhplz.com"
url = "http://www.baidu.com"
val = tldextract.extract(url)
print(val.domain,val.suffix,val.registered_domain,val.ipv4,val.subdomain,val.fqdn)
结果
baidu com baidu.com www www.baidu.com