python
pip install GeoIP
pip install python-geoip-geolite2
python
from geoip import geolite2
def get_location(ip_address):
match = geolite2.lookup(ip_address)
if match:
return match.country, match.city, match.lat, match.lon
else:
return None
location = get_location(ip)
if location:
country, city, latitude, longitude = location
else: