Skip to content

Instantly share code, notes, and snippets.

@e96031413
Created January 29, 2020 02:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save e96031413/fabb571506b8f34bdd79b7d7ab79ecad to your computer and use it in GitHub Desktop.
Save e96031413/fabb571506b8f34bdd79b7d7ab79ecad to your computer and use it in GitHub Desktop.
How To find the location info with geocoder
#pip install geocoder
import geocoder
g = geocoder.ip('me')
g.latlng
#Out[1]: [22.0063, 120.3933]
g.address
#Out[2]: 'Kaohsiung, Takao, TW'
g.geojson
#Out[3]:{'type': 'FeatureCollection', 'features':
[{'type': 'Feature', 'properties': {'address': 'Kaohsiung, Takao, TW',
'city': 'Kaohsiung', 'country': 'TW', 'hostname': 'X.X.X.X',
'ip': 'X.X.X.X', 'lat': 22.0063, 'lng': 120.3933, 'ok': True,
'org': 'AS7532 DigiCentre Company Limited,',
'raw': {'ip': 'X.X.X.X', 'hostname': 'X.X.X.X',
'city': 'Kaohsiung', 'region': 'Takao', 'country':
'TW', 'loc': '22.0063,120.3133',
'org': 'AS7532 DigiCentre Company Limited,',
'timezone': 'Asia/Taipei', 'readme': 'https://ipinfo.io/missingauth'},
'state': 'Takao', 'status': 'OK'},
'geometry': {'type': 'Point', 'coordinates': [120.3933, 22.0063]}}]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment