-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathget_ip.py
More file actions
executable file
·38 lines (33 loc) · 1.15 KB
/
get_ip.py
File metadata and controls
executable file
·38 lines (33 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python
# -*- coding: utf-8 -*-
###############################################################################
# Copyright (c) 2012-2014, Gianluca Fiore
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
###############################################################################
__author__ = "Gianluca Fiore"
__license__ = "GPLv3"
__version__ = "1.0"
__mantainer__ = "Gianluca Fiore"
__date__ = "20110303"
__email__ = "forod.g@gmail.com"
__status__ = "stable"
import sys
import urllib.request
import json
JSONIP4 = 'https://ipv4.jsonip.com/'
JSONIP6 = 'https://ipv6.jsonip.com/'
def main():
f4 = urllib.request.urlopen(JSONIP4)
f6 = urllib.request.urlopen(JSONIP6)
ip4 = json.loads(f4.read().decode('utf-8'))
ip6 = json.loads(f6.read().decode('utf-8'))
print("Your current IPv4 is: %s" % ip4['ip'])
print("Your current IPv6 is: %s" % ip6['ip'])
if __name__ == '__main__':
status = main()
sys.exit(status)