国内推荐的DNS解析地址主要有以下几个:
import socket
def resolve_dns(domain, dns_server):
try:
result = socket.gethostbyname_ex(domain, resolver=None, family=socket.AF_INET, timeout=5, source_address=None, source_port=None, ignore_addresses=None, socket_options=None, server=dns_server)
return result
except socket.gaierror as e:
return str(e)
# 使用示例
domain = "www.example.com"
dns_server = "8.8.8.8"
result = resolve_dns(domain, dns_server)
print(result)
请注意,以上信息仅供参考,实际使用时请根据个人需求和网络环境进行选择。
领取专属 10元无门槛券
手把手带您无忧上云