python提取url中的域名和端口号

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

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