IP address of webserver

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Johny

    #1

    IP address of webserver

    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:

    Reply from 209.85.129.147: bytes=32 time=30ms TTL=244
    Reply from 209.85.129.147: bytes=32 time=30ms TTL=244
    ...
    ...
    So I know that www.google.com has 209.85.129.147 IP address.
    But how can I find it directly from Python script?
    Thanks for help
    J.

  • Paul Rubin

    #2
    Re: IP address of webserver

    "Johny" <python@hope.cz writes:
    So I know that www.google.com has 209.85.129.147 IP address.
    But how can I find it directly from Python script?
    >>import socket
    >>print socket.gethostb yname('www.goog le.com')
    66.102.7.147
    >>>

    Comment

    • Gabriel Genellina

      #3
      Re: IP address of webserver

      "Johny" <python@hope.cz escribió en el mensaje
      news:1169918690 .690636.42690@a 75g2000cwd.goog legroups.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?
      pyimport socket
      pyhelp(socket.g ethostbyname)
      Help on built-in function gethostbyname in module _socket:

      gethostbyname(. ..)
      gethostbyname(h ost) -address

      Return the IP address (a string of the form '255.255.255.25 5') for a
      host.

      pysocket.gethos tbyname("www.go ogle.com")
      '209.85.165.147 '

      --
      Gabriel Genellina


      Comment

      Working...