I need to write a program that retrieves the IP addresses of a list of domain names. The simple example can be shown here:
>>> import socket
>>> socket.gethostbyname('google.com')
'172.217.160.14'
>>> socket.close()
After I try to close the socket, I get this error:
Traceback (most recent call last): File "", line 1, in AttributeError: module 'socket' has no attribute 'close'
How can I close this socket? I need to close it because my actual program has loop where in each domain name in the list I needs to get its IP, so I need to close the socket in each iteration for the new host.
Can you tell me what is the problem?