Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env python
- import dpkt, socket, pygeoip, optparse
- gi = pygeoip.GeoIP("/opt/GeoIP/Geo.dat")
- def retGeoStr(ip):
- try:
- rec = gi.record_by_name(ip)
- city = rec['city']
- country = rec['country_code3']
- if (city!=''):
- geoLoc= city+", "+country
- else:
- geoLoc=country
- return geoLoc
- except:
- return "Unregistered"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement