# request_url : 返回 处理后的 (domain,url,domain_url )
# - : (-,-,-)
# http://xx/cc : (xx,/cc,xx/cc)
# / 或者 '' : ( /,/,/ )
# http://xx/?a=a : (xx,/?a=a,xx/?a=a)
# http://xx?a=a : (xx,?a=a,xx?a=a)
#
# /it/shopping/mobile/ : (/,/it/shopping/mobile/,/it/shopping/mobile/)
def _getDomainUrl(self,request_url) :
if request_url in ['','/']: return ('/','/','/')
if request_url == '-' : return ('-','-','-')
domain,url = ("","")
http_num = request_url.find('http://')+7
https_num = request_url.find('https://')+8
if http_num >= 7 : request_url = request_url[http_num:]
if https_num >= 8 : request_url = request_url[https_num:]
ux,uw = request_url.find('/'),request_url.find('?')
if ux==-1 and uw==-1 :
spl = -1
elif ux!=-1 and uw!=-1 :
spl = min( ux,uw )
else :
if ux!=-1 :spl = ux
elif uw!=-1 : spl = uw
if spl == -1 :
domain = request_url
url = '/'
else :
domain = request_url[:spl]
url = request_url[spl:]
if url == '/' : domain_url = domain
else : domain_url = domain + url
if domain == '' : domain = '/'
return (domain,url,domain_url)
|