给定网址,通过这段python代码可以很容易获取域名信息
import urlparse url = "http://www.75271.com" domain = urlparse.urlsplit(url)[1].split(':')[0] print "The domain name of the url is: ", domain
输出结果
The domain name of the url is: www.75271.com
给定网址,通过这段python代码可以很容易获取域名信息
import urlparse url = "http://www.75271.com" domain = urlparse.urlsplit(url)[1].split(':')[0] print "The domain name of the url is: ", domain
输出结果
The domain name of the url is: www.75271.com