python提取url中的域名和端口号
- import urllib
- proto, rest = urllib.splittype("http://www.open-open.com/")
- host, rest = urllib.splithost(rest)
- print host
- host, port = urllib.splitport(host)
- if port is None:
- port = 80
- print port
来源: http://www.phpxs.com/code/1005019/