想获取一条 url 的全部 CName,网上找到一段代码:
from dns import resolver
ans = resolver.query("
www.chinacache.com", "A")
print("qname:",ans.qname)
print ("reclass:",ans.rdclass)
print ("rdtype:",ans.rdtype)
print ("rrset:",ans.rrset)
print ("response:",ans.response)
经 pycharm 编译后报错:
Traceback (most recent call last):
File "D:/OneDrive/Kingsoft/Python/Sublime_workspace/
1.py", line 4, in <module>
ans = resolver.query("
www.baidu.com", "A")
File "C:\Program Files\Python36\lib\site-packages\dns\
resolver.py", line 1132, in query
raise_on_no_answer, source_port)
File "C:\Program Files\Python36\lib\site-packages\dns\
resolver.py", line 1051, in query
raise NXDOMAIN(qnames=qnames_to_try, responses=nxdomain_responses)
dns.resolver.NXDOMAIN: None of DNS query names exist:
www.baidu.com.,
www.baidu.com.ksyun.com., www.baidu.com.192.168.12.18., www.baidu.com.192.168.12.19., www.baidu.com.114.114.114.114.,
www.baidu.com.ksyun.com., www.baidu.com.192.168.12.18., www.baidu.com.192.168.12.19., www.baidu.com.114.114.114.114.,
www.baidu.com.kingsoft.cn.
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
https://www.v2ex.com/t/452207
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.