IP address

Klaus Alexander Seistrup klaus at seistrup.dk
Sun Jan 28 11:26:57 CET 2007


Scripter47 wrote:

> How do i get my ip address?
>
> in cmd.exe i just type "ipconfig" then it prints:
>       ...
>       IP-address . . . . . . . . . . . . . . . . . : 192.168.1.10
>       ...
> how can i do that in python??

#v+

python -c 'import re, urllib; print re.findall("<title>Your IP: (.+?)</title>", urllib.urlopen("http://myip.dk/").read())[0]'

#v-

Cheers,

-- 
Klaus Alexander Seistrup
http://klaus.seistrup.dk/




More information about the Python-list mailing list