Skip to content

Instantly share code, notes, and snippets.

@afrida67
Created December 9, 2018 07:33
Show Gist options
  • Save afrida67/03addc67398e8179be44ee4ff8179f42 to your computer and use it in GitHub Desktop.
Save afrida67/03addc67398e8179be44ee4ff8179f42 to your computer and use it in GitHub Desktop.
Find geolocation information about an IP
'''
Sample Input
63.70.164.200
168.12.13.1
Sample Output
Lincoln (Highlands), Nebraska (United States)
Atlanta (150), Georgia (United States)
'''
##install: pip install ipapi
import ipapi
ip_address = str(input("Enter the IP address\n" ))
print("Country : ",ipapi.location(ip_address, None, 'country'))
print("City : ",ipapi.location(ip_address, None, 'city'))
print("Region : ",ipapi.location(ip_address, None, 'region'))
#print(ipapi.location(ip='168.12.13.1', key=None, field=None))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment