def isProgramURL(url: str, acceptAll=True) -> bool:
""" Whether the given url is a program URL """
domain = urlparse(url).netloc.split(':')[0].lower()
if not config.domains:
return True
if config.domains or (not acceptAll):
try:
ip = socket.gethostbyname(domain)
except (socket.gaierror, UnicodeError):
ip = None
if domain and isinstance(config.domains, list):
return (any([domain.endswith(hostname.lower()) for hostname in config.domains]) and
ip != '127.0.0.1')
return False
if acceptAll:
return True
评论列表
文章目录