Skip to content

Instantly share code, notes, and snippets.

@Sh1n0g1
Created December 21, 2016 01:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Sh1n0g1/86a0bdcacb8e75b79ce7661bbe345cc5 to your computer and use it in GitHub Desktop.
Save Sh1n0g1/86a0bdcacb8e75b79ce7661bbe345cc5 to your computer and use it in GitHub Desktop.
IP2geolocation
#Bulk IP Address 2 Geolocation Using freegeoip.net
#Input: IP Address List
#Output: IP, Latitude, Longitude (CSV Format)
import urllib, json
#Paste your ipaddress list
ips="""
1.1.1.1
2.2.2.2
3.3.3.3
"""
for ip in ips.splitlines():
if ip != "":
url = "http://freegeoip.net/json/" + ip
response = urllib.urlopen(url)
data=json.loads(response.read())
print ip + "," + str(data['latitude']) + "," + str(data['longitude'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment