title: How to find location with IP address in Python?
body: <p>I am developing a project, that needs to store user location in my data base. I got the public IP address of that user. But I am unable to get the user location. I have tried several ways (from <em>StackOverflow</em>) but I didn't find any hint. Like the below</p>
  
  <pre><code>url = urllib.urlopen("http://api.hostip.info/get_html.php?ip=%s&amp;position=true" % ip)
  data = re.compile('^[^\(]+\(|\)$').sub('', url.read())
  print data
  </code></pre>
  
  <p>but I am getting the result as</p>
  
  <pre><code>Unknown Country?) (XX)
  City: (Unknown City?)
  </code></pre>
  
  <p>another way:</p>
  
  <pre><code>import urllib
  
  response = urllib.urlopen("http://api.hostip.info/get_html.php?ip={}&amp;position=true".format(ip)).read()
  
  print(response)
  </code></pre>
  
  <p>but the result is</p>
  
  <pre><code>Country: (Unknown Country?) (XX)
  City: (Unknown City?)
  
  Latitude: 
  Longitude: 
  IP: 115.xxx.xxx.xx
  </code></pre>
  
  <p>Any help would be appreciated!</p>