Skip to content

Domain to IP

#!/usr/bin/python3
import socket


def report(input_str):
    with open('output.txt', 'a') as f:
        print(input_str)
        f.write(input_str + '\n')


with open("input.txt") as file:
    lines = file.readlines()
    for target_line in lines:
        target = target_line.strip()
        try:
            report("| " + target + " | " + socket.gethostbyname(target) + " |")
        except:
            report("| " + target + " | error |")

input.txt

example.com
example.pl