Welcome, guest | Sign In | My Account | Store | Cart

In addition to the posts about IPv4. Examples on Python.

Text, 15 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# Python 2
from urllib2 import urlopen, Request
from re import search

f = urlopen(Request("http://internet.yandex.ru/"))
print search('IPv4:\s(\d+\.){3}\d+', f.read()).group(0)
f.close()

# Python 3
from urllib.request import urlopen
from re import compile, search

f = urlopen("http://internet.yandex.ru/")
print(compile('IPv4:\s(\d+\.){3}\d+').search(str(f.read())).group(0))
f.close()