python 从url中提取域名和pat
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
相关文章