How to get the HOST IP through the PYTHON domain?

Asked

Viewed 1,665 times

4

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

PHP example:

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

And in Python? How can I do this?

1 answer

5

In reality python is almost that:

import socket
socket.gethostbyname('www.google.com') # 216.58.211.196

Browser other questions tagged

You are not signed in. Login or sign up in order to post.