python3 批量处理域名解析
- 域名批量解析,快速确认域名的存活性及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 批量处理域名解析的更多相关文章
- python3批量删除豆瓣分组下的好友
python3批量删除豆瓣分组下的好友 """ python3批量删除豆瓣分组下的好友 2016年6月7日 03:43:42 codegay 我两年前一时冲动在豆瓣关注了 ...
- Python3 批量更改文件后缀名
Python3 批量更改文件后缀名 示例: # coding:utf8 import os import sys def Rename(): #Path = "F:\\test\\" ...
- Python3 批量替换文本内容
Python3 批量替换文本内容 示例: # coding:utf8 import os; def reset(): i = 0 path = r"H:\asDemo\workdemo\aw ...
- Python3批量爬取网页图片
所谓爬取其实就是获取链接的内容保存到本地.所以爬之前需要先知道要爬的链接是什么. 要爬取的页面是这个:http://findicons.com/pack/2787/beautiful_flat_ico ...
- python3 批量管理Linux服务器 下发命令与传输文件
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import paramiko import os, stat import sys import ope ...
- python3批量查询域名是否注册
#!/usr/local/bin/python3 #coding=utf-8 import re,sys,os,random,time, base64 import urllib.parse, url ...
- Python3 批量修改JPG图片尺寸
功能 批量修改当前文件夹下的jpg图片到设置的尺寸 将修改后的图片移动到 new_img 这个文件夹下 导入库 from PIL import Image # 处理图片模块 import os imp ...
- python3 批量缩放图片为iphone5的640*1136以下
try: from PIL import Image, ImageDraw, ImageFont, ImageEnhance except ImportError: import Image, Ima ...
- Python3批量修改指定目录下面的图片/文件名
需求: 从网上下载的N张.png图片保存到image目录中,将下载下来的图片全部重命名test1.png/test2.png... 实现代码: 目录结构: config-->setting.py ...
随机推荐
- jmespath(2)投影Projections
投影 投影是JMESPath的关键特性之一.它允许您将表达式应用于元素集合.有五种投影: 列表投影 切片投影 对象投影 展平投影 过滤投影 处理投影需要注意的点 投影评估分为两个步骤.左侧(LHS)创 ...
- Python 分析热卖年货,今年春节大家都在送啥?
今年不知道有多少小伙伴留在原地过年,虽然今年过年不能回老家,但这个年也得过,也得买年货,给家人长辈送礼.于是我出于好奇心的想法利用爬虫获取某宝数据,并结合 Python 数据分析和第三方可视化平台来分 ...
- Zabbix 监控项更多用法
监控服务端口状态 配置 Zabbix 提供的检测器 配置自定义值映射 查看监控项数据状态 触发器配置 自定义监控项 TCP 11 种状态 TCP 11 种状态 LISTEN - 侦听来自远方TCP端口 ...
- Linux-源码安装及FPM打包
目录 源码安装 制作RPM包(使用FPM工具) 安装rpm后要执行的脚本(优化版) 源码安装 这里举例Nginx的源码安装,需要前往Nginx官网找到稳定版本源码安装包下载. ## 源码安装nginx ...
- Linux添加系统调用
Linux添加系统调用 1 概述 通常添加系统调用有两种方案: * 重新编译内核 * 添加内核模块 此处我们采用重新编译内核的方式增加系统调用. 实验环境:X86_64 GNU/Linux 4.15. ...
- centos7+腾讯云服务器搭建wordpress
title: centos7+腾讯云服务器搭建wordpress date: 2020-03-04 categories: web tags: [wordpress] 分两部分:1.搭建LEMP环境 ...
- Leetcode 30 串联所有单词的子串 滑动窗口+map
见注释.滑动窗口还是好用. class Solution { public: vector<int> findSubstring(string s, vector<string> ...
- POJ - 3665 icow
Fatigued by the endless toils of farming, Farmer John has decided to try his hand in the MP3 player ...
- JxBrowser: 6.6.1 Crack
JxBrowser: 6.6.1. 1. RELEASE NOTES Download:HomePage JxBrowser is a cross-platform library that prov ...
- whiteboard & coding interview practice
whiteboard & coding interview practice 白板 & 面试 & 编码练习 Algorithm https://www.freecodecamp ...