def same_domain(url1, url2):
 if (not url1.isValid()):
  raise InvalidUrlError(url1)
 if (not url2.isValid()):
  raise InvalidUrlError(url2)
 suffix1 = url1.topLevelDomain()
 suffix2 = url2.topLevelDomain()
 if (suffix1 == ''):
  return (url1.host() == url2.host())
 if (suffix1 != suffix2):
  return False
 domain1 = url1.host()[:(- len(suffix1))].split('.')[(-1)]
 domain2 = url2.host()[:(- len(suffix2))].split('.')[(-1)]
 return (domain1 == domain2)

def same_domain ( url1 , url2 ) : if ( not url1 . isValid ( ) ) : raise InvalidUrlError ( url1 ) if ( not url2 . isValid ( ) ) : raise InvalidUrlError ( url2 ) suffix1 = url1 . topLevelDomain ( ) suffix2 = url2 . topLevelDomain ( ) if ( suffix1 == '' ) : return ( url1 . host ( ) == url2 . host ( ) ) if ( suffix1 != suffix2 ) : return False domain1 = url1 . host ( ) [ : ( - len ( suffix1 ) ) ] . split ( '.' ) [ ( - 1 ) ] domain2 = url2 . host ( ) [ : ( - len ( suffix2 ) ) ] . split ( '.' ) [ ( - 1 ) ] return ( domain1 == domain2 )
check if url1 and url2 belong to the same website .