Skip to content

Instantly share code, notes, and snippets.

# Fetch latitude and longitude from freegeoip
import urllib2
import json
def geo(ip=''):
g = urllib2.urlopen('http://freegeoip.net/json/%s' % ip)
geo = json.loads(''.join(g))
return geo['latitude'], geo['longitude']
geo()