IP address of webserver
Gabriel Genellina
gagsl-py at yahoo.com.ar
Sat Jan 27 13:21:12 EST 2007
"Johny" <python at hope.cz> escribió en el mensaje
news:1169918690.690636.42690 at a75g2000cwd.googlegroups.com...
> How can I find server's IP address?
>>From console I can use ping, for example:
>
> C:\RobotP\cgi-bin>ping www.google.com
> Pinging www.google.com [209.85.129.147] with 32 bytes of data:
> [...]
> But how can I find it directly from Python script?
py> import socket
py> help(socket.gethostbyname)
Help on built-in function gethostbyname in module _socket:
gethostbyname(...)
gethostbyname(host) -> address
Return the IP address (a string of the form '255.255.255.255') for a
host.
py> socket.gethostbyname("www.google.com")
'209.85.165.147'
--
Gabriel Genellina
More information about the Python-list
mailing list