Hi ,
The below Script helps you to get Public IP-Address.This script uses the third party website to get the IP-Address
The script works on both Logged-in and System User
Please refer the following URL for your reference
https://scripts.comodo.com/frontend/web/topic/get-your-public-ip-address
import urllib2,re,ssl,os,socket,sys,platform,uuid
print "Computer Name: " +socket.gethostname()
req = urllib2.Request('https://iplocation.net/')
context = ssl._create_unverified_context()
c=0
res = urllib2.urlopen(req,context=context)
data = res.read()
patterns = re.findall('href="\/go\/ip2location(.*)
(.*)
(.*)
(.*)
(.*)
(.*)
(.*)
(.*)
(.*)
(.*)
(.*)
(.*)
(.*)
(.*)
(.*)
(.*)
(.*)
(.*)
(.*)
(.*)
(.*)
(.*)
(.*)
(.*)
(.*)
(.*)
(.*)
(.*)
(.*)',data)
values = ','.join(str(v) for v in patterns)
ki=re.findall('<td>(.*)<',values)
list1=[]
Data=ki[0].split('<')
Data[25]=Data[25].strip('td>')
dict={'Your Public IP Address is ':Data[0]}
for keys,values in dict.items():
print keys +" = "+values
20170713-Public_IP-Address.json (1.27 KB)