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 ...
随机推荐
- TZ_05_Spring_事物的xml开发和annotation开发
1.Spring_事物的xml开发 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns=& ...
- 如何获取Expression Design 4工具与Expression Blend 4工具
在VS2010+C#+WPF 开发项目过程中涉及到界面的布局与设计,网上有人讲采用Expression Design 4与Expression Blend 4工具相当方便, 于是决定试看看,下面将这个 ...
- 读书笔记--Struts 2 in Action 目录
1.Struts 2:现代Web框架 1.1 web应用程序:快速学习 21.1.1 构建web应用程序 21.1.2 基础技术简介 31.1.3 深入研究 61.2 web应用程序框架 71.2.1 ...
- Intent 传递Map数据
android开发默认情况下,通过Bundle bundle=new Bundle();传递值是不能直接传递map对象的,解决办法: 第一步:封装自己的map,实现序列化即可 /** *序列化map供 ...
- el表达式 jsp页面取list的长度
方法1 ${cimlistForJsp.size()} 方法2,引入 <%@ taglib prefix="fn" uri="http://java.sun.com ...
- 根据一个分类id 获取这个分类底下所有子分类的商品信息,根据下面方法查询出所有有关分类id 再 根据这些id去商品表里查询所有商品信息
/** * 检测该分类下所有子分类,并输出ID(包括自己) * 数据库字段 catid pid */ function getChildrenIds ($sort_id){ include_once ...
- Django用户登陆以及跳转后台管理页面3
Django用户登陆以及跳转后台管理页面1http://www.cnblogs.com/ujq3/p/7891774.html Django用户登陆以及跳转后台管理页面2http://www.cnbl ...
- Hdu 4251 区间中位数(划分树)
题目链接 The Famous ICPC Team Again Time Limit: 30000/15000 MS (Java/Others) Memory Limit: 32768/3276 ...
- LintCode 合并二维数组
合并两个排序的整数数组A和B变成一个新的数组. 样例 给出A=[1,2,3,4],B=[2,4,5,6],返回 [1,2,2,3,4,4,5,6] 之前想的是用剑指offer里替换空格那种方法 但是把 ...
- httpserver支持路由传输控制器
main.go package main import ( "net/http" "com.jtthink.net/myhttpserver/core" ) t ...