#coding:utf-8
import urllib
#根据URL获取域名
def getdomain(url):
proto, rest = urllib.splittype(url)
host, rest = urllib.splithost(rest)
return host print getdomain("http://www.cnblogs.com/goodhacker/admin/EditPosts.aspx?opt=1")
输出结果为:www.cnblogs.com
2022-11-12 16:27:07
#coding:utf-8
import urllib
#根据URL获取域名
def getdomain(url):
proto, rest = urllib.splittype(url)
host, rest = urllib.splithost(rest)
return host print getdomain("http://www.cnblogs.com/goodhacker/admin/EditPosts.aspx?opt=1")
输出结果为:www.cnblogs.com
下一篇:Mongo聚合函数