• 域名批量解析,快速确认域名的存活性及IP地址,脚本中包含了具体的用法和简要说明
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# python3.6 from socket import gethostbyname
import argparse def domain_ip(openfile,out1,out2,out3):
with open(openfile, 'r') as f:
for line in f.readlines():
try:
host = gethostbyname(line.strip('\n')) # 域名反解析得到的IP
except Exception as e:
with open(out1, 'a+') as ERR: # A-domain-ERR.txt 解析出错域名统计
ERR.write(line.strip() + '\n')
else:
with open(out2, 'a+') as r: # A-domain-ip.txt 里面存储的是批量解析后的结果,输出域名
r.write(line.strip('\n') + ' '+ host +"\n") # 显示有ip绑定的域名,用空格隔开
re = line.strip('\n')
print(re,host)
#不包含的解析结果
if host.strip() != "127.0.0.0":
if host.strip()!= "192.168.1.1":
if host.strip() != "192.168.2.1":
if host.strip() != "192.168.3.1":
with open(out3,"a+") as f:
f.write(host.strip()+"\n")
#f.write(line.strip()+" " + host.strip()+"\n")
else:
pass
else:
pass
else:
pass
else:
pass if __name__== "__main__":
parser = argparse.ArgumentParser(description="2020.07.28 python 3.6 domain_1.0")
parser.add_argument('-f'.strip(),'--filename'.strip(), help='eg:-f domains.txt')# 需要解析的域名列表信息
parser.add_argument('-o'.strip(),'--outfile1'.strip(), default="A-domain-ERR.txt",help='eg:-o A-domain-ERR.txt ')# 输出解析失败的域名信息
parser.add_argument('-r'.strip(),'--outfile2'.strip(), default="A-domain-ip.txt",help='eg:-r A-domain-ip.txt ')#输出解析成功的域名及ip信息
parser.add_argument('-a'.strip(), '--outfile3'.strip(), default="A-lists.txt",help='eg:-a A-lists.txt ')#输出A记录列表
args = parser.parse_args()
if (args.filename and args.outfile1 and args.outfile2 and args.outfile3):
domain_ip(args.filename, args.outfile1,args.outfile2,args.outfile3)
else:
print(parser.format_help())

python3 批量处理域名解析的更多相关文章

  1. python3批量删除豆瓣分组下的好友

    python3批量删除豆瓣分组下的好友 """ python3批量删除豆瓣分组下的好友 2016年6月7日 03:43:42 codegay 我两年前一时冲动在豆瓣关注了 ...

  2. Python3 批量更改文件后缀名

    Python3 批量更改文件后缀名 示例: # coding:utf8 import os import sys def Rename(): #Path = "F:\\test\\" ...

  3. Python3 批量替换文本内容

    Python3 批量替换文本内容 示例: # coding:utf8 import os; def reset(): i = 0 path = r"H:\asDemo\workdemo\aw ...

  4. Python3批量爬取网页图片

    所谓爬取其实就是获取链接的内容保存到本地.所以爬之前需要先知道要爬的链接是什么. 要爬取的页面是这个:http://findicons.com/pack/2787/beautiful_flat_ico ...

  5. python3 批量管理Linux服务器 下发命令与传输文件

    #!/usr/bin/env python3 # -*- coding: utf-8 -*- import paramiko import os, stat import sys import ope ...

  6. python3批量查询域名是否注册

    #!/usr/local/bin/python3 #coding=utf-8 import re,sys,os,random,time, base64 import urllib.parse, url ...

  7. Python3 批量修改JPG图片尺寸

    功能 批量修改当前文件夹下的jpg图片到设置的尺寸 将修改后的图片移动到 new_img 这个文件夹下 导入库 from PIL import Image # 处理图片模块 import os imp ...

  8. python3 批量缩放图片为iphone5的640*1136以下

    try: from PIL import Image, ImageDraw, ImageFont, ImageEnhance except ImportError: import Image, Ima ...

  9. Python3批量修改指定目录下面的图片/文件名

    需求: 从网上下载的N张.png图片保存到image目录中,将下载下来的图片全部重命名test1.png/test2.png... 实现代码: 目录结构: config-->setting.py ...

随机推荐

  1. log查看工具log2console

    log查看工具log2console介绍:https://www.cnblogs.com/TianFang/archive/2013/03/27/2985296.html Log2Console日志监 ...

  2. 使用 Typecho 搭建博客

    nginx 配置文件 [root@dbtest ~]# cat /etc/nginx/conf.d/www.typecho.com.conf server { listen 80; server_na ...

  3. select用法&原理详解(源码剖析)(转)

    今天遇到了在select()前后fd_set的变化问题,查了好久终于找到一个有用的帖子了,很赞,很详细!!原文链接如下: select用法&原理详解(源码剖析) 我的问题是: 如下图示:在se ...

  4. PTA L1-006 连续因子【暴力模拟】

    一个正整数N的因子中可能存在若干连续的数字.例如630可以分解为3*5*6*7,其中5.6.7就是3个连续的数字.给定任一正整数N,要求编写程序求出最长连续因子的个数,并输出最小的连续因子序列. 输入 ...

  5. bash copy multi files

    bash copy multi files # copy one file $ cp file1.js /var/www/html # copy multi files ??? no space $ ...

  6. Google reCAPTCHA 2 : Protect your site from spam and abuse & Google reCAPTCHA 2官方教程

    1

  7. Awesome GitHub Topics

    Awesome GitHub Topics freeCodeCamp https://github.com/topics/javascript?o=desc&s=stars https://g ...

  8. js 快速排序 All In One

    js 快速排序 All In One 快速排序 / Quick Sort "use strict"; /** * * @author xgqfrms * @license MIT ...

  9. free website generator by google

    free website generator by google https://sites.google.com/view/webgeeker-xyz/首页 https://sites.google ...

  10. Interview of Chinese IT companies Ratings and Reviews website/app

    Interview of Chinese IT companies Ratings and Reviews website/app // js hack const getShitRank = (st ...