def url_is_from_any_domain(url, domains):
 host = parse_url(url).hostname
 if host:
  return any((((host == d) or host.endswith(('.%s' % d))) for d in domains))
 else:
  return False

def url_is_from_any_domain ( url , domains ) : host = parse_url ( url ) . hostname if host : return any ( ( ( ( host == d ) or host . endswith ( ( '.%s' % d ) ) ) for d in domains ) ) else : return False
return true if the url belongs to any of the given domains .