这里给定网址,通过下面这段python代码可以很容易获取域名信息
import urlparse url = "http://HdhCmsTestbitsCN测试数据" domain = urlparse.urlsplit(url)[1].split(':')[0] print "The domain name of the url is: ", domain
输出结果如下:
The domain name of the url is: HdhCmsTestbitsCN测试数据
希望本文所述对大家的Python程序设计有所帮助。
查看更多关于python使用urlparse分析网址中域名的方法的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did90778