🔥
This commit is contained in:
16
i3blocks/ipaddress.py
Executable file
16
i3blocks/ipaddress.py
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/python
|
||||
from urllib.request import urlopen
|
||||
from xml.etree import ElementTree as ET
|
||||
|
||||
url = 'http://freegeoip.net/xml/'
|
||||
|
||||
with urlopen(url) as res:
|
||||
s = res.read()
|
||||
|
||||
root = ET.fromstring(s)
|
||||
|
||||
ip = root.find('IP').text
|
||||
country = root.find('CountryName').text
|
||||
|
||||
print('/ %s (%s)' % (ip, country))
|
||||
print('/ %s (%s)' % (ip, country))
|
||||
Reference in New Issue
Block a user