ToKeiChun

Domain to IP Address

Jan 3rd, 2021 (edited)
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. #!/usr/bin/python3
  2. # python3 dotoip.py list.txt
  3. # list without http://
  4. # source : https://github.com/dextercyberlab/Domain-to-IP-Converter
  5. import socket
  6. d = []
  7.  
  8. def domaintoip(file):
  9.     with open(file) as t:
  10.         for Hostname in t: 
  11.             Hostname = Hostname.rstrip()
  12.             try:
  13.                 s = socket.gethostbyname(Hostname)
  14.                 d.append(s)
  15.                 print(Hostname + ' ===> ' + s)
  16.             except:
  17.                 print(Hostname, 'Not Valid')
  18.                 continue
  19.  
  20.  
  21.     with open('output.txt', 'w') as output:
  22.         for out in d:
  23.             print(out, file=output)
  24.         output.close()
  25.  
  26. f = str(input('Enter the file you want to extract: '))
  27. domaintoip(f)
Add Comment
Please, Sign In to add comment