IP address by domain name

I am trying to get the domain IP address. I am using the following code

>> import socket >> socket.gethostbyname('www.google.com') 

which gives me the following error.

 Traceback (most recent call last): File "<pyshell#18>", line 1, in <module> socket.gethostbyname('www.google.com') gaierror: [Errno 11001] getaddrinfo failed 

what's wrong with my code ... is there any other way to get the ip address by domain name in python .. ??? please, help...

+6
source share
2 answers

Your code is correct. Perhaps you have a firewall between you and these servers that blocks the request?

+12
source

This error also appears if the domain is not located anywhere (it is not connected to any IP address or to any name server) or simply does not exist.

0
source

Source: https://habr.com/ru/post/890991/


All Articles