def get_base_url(url):
 url_host = urlparse(url).hostname
 if url_host:
  url_split = url_host.split('.')
  if (len(url_split) < 3):
   return url_host
  return '.'.join((((len(url_split[(-2)]) < 4) and url_split[(-3):]) or url_split[(-2):]))
 else:
  return ''

def get_base_url ( url ) : url_host = urlparse ( url ) . hostname if url_host : url_split = url_host . split ( '.' ) if ( len ( url_split ) < 3 ) : return url_host return '.' . join ( ( ( ( len ( url_split [ ( - 2 ) ] ) < 4 ) and url_split [ ( - 3 ) : ] ) or url_split [ ( - 2 ) : ] ) ) else : return ''
return base url for site .