Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Transfer domain name to ip address in batch

Shulou Source: shulou.com Published: 2022-06-01 02:43:05 10月04日 Update

Disadvantages: single thread

Purpose: if you have a local dns on the intranet, you can get the domain name, the intranet real ip.

#-*-coding=utf-8-*-# date: may 6, 2015 # author: sanr import socketdef ip (name): try: result = socket.getaddrinfo (name None) return result [0] [4] [0] except: return 0 if _ name__=='__main__': f = open ('url.txt') for line in f: print line.strip () +' + str (ip (line.rstrip () f.close ()

Or the following code mainly does not have to close the handle by itself

Import socketdef ip (name): try: result = socket.getaddrinfo (name, None) return result [0] [4] [0] except: return 0 if _ name__=='__main__': with open ('url.txt' 'r') as f: for line in f.readlines (): print line.strip () +'+ str (ip (line.rstrip ()

Tags: Domain name no code handle purpose thread defect face address Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Linux Microsoft Huawei Docker