I'm trying to resolve in Python a list of IP addresses in a file. Apparently the question is not new but I don't understand why my small code is not working.
import socket
with open(r'C:\TMG_logs\web_IP_10', 'r') as r_file:
with open(r'C:\TMG_logs\web_IP_10_hosts', 'w') as w_file:
for ip in r_file.readline():
host = socket.gethostbyaddr(ip)
w_file.write(host + ' - ' + ip + '\n')
I'm getting:
socket.gaierror: [Errno 11001] getaddrinfo failed
And I don't understand why. Thanks in advance for your time!