How to get the HOST IP through the domain in PYTHON?

4

In PHP, to get the ip of a given domain, I usually use the gethostbyname function.

PHP example:

gethostbyname('www.google.com'); //201.17.165.210

What about Python? How can I do this?

    
asked by anonymous 20.07.2016 / 18:19

1 answer

5

Actually in python it's almost that:

import socket
socket.gethostbyname('www.google.com') # 216.58.211.196
    
20.07.2016 / 18:23