• python根据域名循环遍历查找绑定IP


    # encoding: UTF-8
    import socket
     
    rfile = open('c:\\ip.txt')
    wfile = open('c:\\result.csv', 'w+')
    for line in rfile:
        str = line.strip().split(';')
        for s in str:
            s = s.strip().split('/')
            s = s[0]
            try:
                result = socket.gethostbyname(s)
            except:
                result = "error"
            if result == 'error':
                www = 'www'
                nPos = s.find(www)
                if nPos == -1:
                    s = 'www.' + s
                try:
                    result = socket.gethostbyname(s)
                except:
                    result = "error"
            wfile.write(s + ',' + result)
            wfile.write('\n')
            print s
    rfile.close()
    wfile.close()
  • 相关阅读:
    Linux的命令2
    运维书
    管理MariaDB
    MariaDB基础命令
    Linux创建桥接网络
    聚合网络
    kickstart
    VLAN原理
    进程优先和ACL
    计划任务at、crontab
  • 原文地址:https://www.cnblogs.com/fighter/p/2567529.html
Copyright © 2020-2023  润新知