python 从url中提取域名和path
python2代码
from urlparse import *
url='http://www.chenxm.cc/post/719.html'
res=urlparse(rul)
print res
# ParseResult(scheme='http', netloc='www.chenxm.cc', path='/post/719.html', params='', query='', fragment='')
python3代码
from urllib.parse import urlparse
url='http://www.chenxm.cc/post/719.html'
res=urlparse(rul)
print (res )
# ParseResult(scheme='http', netloc='www.chenxm.cc', path='/post/719.html', params='', query='', fragment='')
http://www.chenxm.cc/post/720.html