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 ...
随机推荐
- SpringMVC注解开发方式
环境准备 springmvc版本:spring3.2 需要spring3.2所有jar(一定包括spring-webmvc-3.2.0.RELEASE.jar 工程结构 配置前端控制器(web.xml ...
- leetcode 448 - 476
448. Find All Numbers Disappeared in an Array Input: [4,3,2,7,8,2,3,1] Output: [5,6] 思路:把数组的内容和index ...
- echarts--例子
echarts使用例子: <script type="text/javascript"> option = { title : {'x': 'center','y':' ...
- PHP--http_build_query--把数组化成&key=value方式
- draft.js开发富文本编辑器
写在前头的话 在react中去寻找一个好用的富文本编辑器网上很少有推荐的,搜到的也只有一些个人不成熟的作品,慢慢发现网上比较推荐的一个东东叫做draft.js. 这个东西在网上可以找到的教程也是手指头 ...
- Eular质数筛法
小Hi:我们可以知道,任意一个正整数k,若k≥2,则k可以表示成若干个质数相乘的形式.Eratosthenes筛法中,在枚举k的每一个质因子时,我们都计算了一次k,从而造成了冗余.因此在改进算法中,只 ...
- vue跨域,复杂请求,后端为beego
关于跨域,网上讲得很多,具体实施起来大多讲的不详细,贴我的vue端代码 require('es6-promise').polyfill() import fetch from 'isomorphic- ...
- Spring Boot邮件功能
1.应用场景 邮件功能的应用场景可谓十分广泛,诸如注册用户.密码找回,消息通知.以及一些程序异常通知等都需要使用到该功能. 正是由于邮件功能的使用广泛,因此springboot也加在它的组件中添加了邮 ...
- golang学习资料必备
核心资料库 https://github.com/yangwenmai/learning-golang
- Visual studio加载项目时报错 尚未配置为Web项目XXXX指定的本地IIS,需要配置虚拟目录。解决办法。
在SVN上下载工程项目.使用visual studio打开时,出现如下提示: 查找相关资料,解决办法如下: 使用记事本打开工程目录下的.csproj文件.把<UseIIS>False< ...