dnspython
dnspython
一个Python实现的一个DNS工具包,利用其查询功能来实现dns的服务监控及解析结果的校验。
安装
pip install dnspython
解析域名为IP
from dns import resolver
f = open('ddd.log', 'w')
with open('urls.txt', 'r') as fp:
for line in fp:
try:
url = line[7:].strip()
ans = resolver.query(url, 'A') # A记录,将主机名转换为IP地址;
# for x in ans.response.answer: # 获取结果
# for y in x.items:
# print(y)
t = url + '||Successful!'
except Exception as e:
t = url + '||' + str(e)
print('resolver error!')
finally:
f.write(t + '\n')
f.close()
urls.txt
http://www.lyskjqbyjs.cn
http://www.haict.edu.cn
http://news.kf.cn
http://www.henanjubao.com
http://huixiangtan.smx.net.cn
http://www.hnjnjc.gov.cn
...
ddd.log
www.lyskjqbyjs.cn||Successful!
www.haict.edu.cn||None of DNS query names exist: www.haict.edu.cn., www.haict.edu.cn.
news.kf.cn||Successful!
www.henanjubao.com||Successful!
huixiangtan.smx.net.cn||Successful!
www.xcxnmj.gov.cn||None of DNS query names exist: www.xcxnmj.gov.cn., wx.hazz-l-
www.yhgq.gov.cn||Successful!
www.zzdangshi.com||Successful!
smx.hnwzj.gov.cn||Successful!
wfxy.ayit.edu.cn||Successful!
www.sqsglj.com||All nameservers failed to answer the query www.sqsglj.com. IN A: Server 127.0.0.53 UDP port 53 answered The DNS operation timed out.; Server 127.0.0.53 UDP port 53 answered The DNS operation timed out.; Server 127.0.0.53 UDP port 53 answered The DNS operation timed out.; Server 127.0.0.53 UDP port 53 answered The DNS operation timed out.; Server 127.0.0.53 UDP port 53 answered The DNS operation timed out.; Server 127.0.0.53 UDP port 53 answered The DNS operation timed out.; Server 127.0.0.53 UDP port 53 answered SERVFAIL
www.yyxsjj.gov.cn||Successful!
...
socket包的gethostbyname(URL)也能解析IP地址,jd不推荐用socket,推荐dnspython。
dnspython的更多相关文章
- CentOS7--DNS处理模块DnsPython的简单使用
初步了解: DnsPython是Python实现的一个DNS工具包,支持几乎所有的记录类型. 安装: # wget http://www.dnspython.org/kits/1.9.4/dnspyt ...
- dnspython模块安装
wget http://www.dnspython.org/kits/1.12.0/dnspython-1.12.0.tar.gz tar -zxvf dnspython-1.12.0.tar.gz ...
- Python的dnspython库使用指南
因为平时在测试DNS的时候有些操作手动完成不方便,所以需要用到脚本,而在Python里dnspython这个用于DNS操作的库十分强大,但是无奈网上大部分资料只列举了少部分的用法,所以记录一下我平时使 ...
- python自动化运维笔记3 —— dns处理模块dnspython
1.3 DNS处理模块 dnspython是python实现的一个DNS工具包,它支持几乎所有的记录类型,可以用于查询.传输并动态更新ZONE信息,同时支持TSIG(事物签名)验证消息和EDNS0(扩 ...
- DNS处理模块dnspython
一.介绍 官网:http://www.dnspython.org/ https://pypi.org/project/dnspython/ dnspython是Python的DNS工具包.它支持几乎所 ...
- 2.python IP/DNS地址处理之IPy/Dnspython模块
1.IPy模块 在IP地址规划中,涉及到计算大量的IP地址,包括网段.网络掩码.广播地址.子网数.IP类型等,即便是专业的网络人员也要进行繁琐的计算,而IPy模块提供了专门针对IPV4地址与IPV6 ...
- python -- DNS处理模块dnspython
简介 dnspython – 是python实现的一个DNS工具包,利用其查询功能来实现dns的服务监控及解析结果的校验 安装dnspython pip install dnspython 使用 常见 ...
- python运维开发常用模块(三)DNS处理模块dnspython
1.dnspython模块介绍: dnspython(http://www.dnspython.org/)是Python实现的一个DNS 工具包,它支持几乎所有的记录类型,可以用于查询.传输并动态更新 ...
- DNS 处理模块 dnspython
简介: dnspython (http://www.dnspython.org/)是Python实现一个DNS的工具包,支持所有的记录类型,可以用于查询.传输并动态更新ZONE信息. 安装 wget ...
随机推荐
- 有趣的纯CSS实现动态晴阴雨雪
我们先来看看实现的效果吧 非常的美腻,对吧.这个是纯css,且单标签实现的哦~ 先贴完整代码,我们再来看看这个里面究竟有什么可以借鉴的知识点 <!DOCTYPE html> <htm ...
- Hackerrank--Savita And Friends(最小直径生成树MDST)
题目链接 After completing her final semester, Savita is back home. She is excited to meet all her friend ...
- Hdu 4965(矩阵快速幂)
题目链接 Fast Matrix Calculation Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K ...
- gomod
package main import "mycore" func main(){ mycore.ShowName() } main.go module mytest requir ...
- Color the ball HDU - 1556 (线段树)
思路:线段树,区间更新 #include<iostream> #include<vector> #include<string> #include<cmath ...
- 常用命令5--文件搜索命令3-find
发现没有出来install.log.syslog ,find不能进行模糊搜索.要想模糊搜索,必须用通配符. 没有所有者的文件是垃圾文件.但是内核产生文件,在这两个文件夹里文件有可能没有所有者,很正常, ...
- 学习Python笔记---if 语句
条件测试 每条if语句的核心都是一个值为True或False的表达式,这种表达式被称为条件测试.Python根据条件测试的值True还是False来决定是否执行if语句中的代码.如果条件测试的值为Tr ...
- 2019.9.28 csp-s模拟测试54 反思总结
咕咕咕的冲动如此强烈x T1x: 看完题目想了想,感觉把gcd不为1的强行放在一组,看作一个连通块,最后考虑连通块之间的组合方式就可以了. 然后维护这个连通块可以写并查集可以连边跑dfs怎么着都行… ...
- 关于Layui 响应式移动端轮播图的问题
用layui做轮播图,在手机上宽度异常, 可通过以下方法解决, 不喜欢layui的同学可以选择Swiper // 轮播图 layui.use('carousel', function () { var ...
- 【CS Round #44 (Div. 2 only) C】Check DFS
[链接]点击打开链接 [题意] 给你一个n节点,m条边的无向联通图. 给你一个节点访问的顺序.(1..n的排列) 你可以改变每个点优先访问的出度.(但必须按照dfs的规则); 问你能不能按照所给的访问 ...