import urllib
proto, rest = urllib.splittype("http://www.baidu.com/11/12.htm")
host, rest = urllib.splithost(rest)
print host
host, port = urllib.splitport(host)
if port is None:
port = 80
print port
转自 :http://www.linuxidc.com/Linux/2011-08/41449.htm
用Python提取url链接中的域名与端口
最新推荐文章于 2024-07-22 19:30:39 发布