I am developing a project that should store the user's location in my database. I received the public IP address of this user. But I can not get the location of the user. I tried several ways (from StackOverflow), but I did not find a hint. As below
url = urllib.urlopen("http://api.hostip.info/get_html.php?ip=%s&position=true" % ip) data = re.compile('^[^\(]+\(|\)$').sub('', url.read()) print data
but I get the result as
Unknown Country?) (XX) City: (Unknown City?)
differently:
import urllib response = urllib.urlopen("http://api.hostip.info/get_html.php?ip={}&position=true".format(ip)).read() print(response)
but the result
Country: (Unknown Country?) (XX) City: (Unknown City?) Latitude: Longitude: IP: 115.xxx.xxx.xx
Any help would be appreciated!
python
Mulagala
source share