Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env python
- import pygeoip
- gi = pygeoip.GeoIP('/opt/GeoIP/Geo.dat')
- def printRecord(tgt):
- rec = gi.record_by_name(tgt)
- city = rec['city']
- region = rec['region_name']
- country = rec['country_name']
- long = rec['longitude']
- lat = rec['latitude']
- print '[*] Target: ' + tgt + 'Geo-located. '
- print '[+] '+str(city)+', '+str(region)+', '+str(country)
- print '[+] Latitude: '+str(lat)+ ', Longitude: '+ str(long)
- tgt = '50.19.217.109'
- printRecord(tgt)
- """ When I run this I get Traceback (most recent call last):
- File "./geoip.py", line 17, in <module>
- printRecord(tgt)
- File "./geoip.py", line 8, in printRecord
- region = rec['region_name']
- KeyError: 'region_name'
- I googled this error and come up with this https://code.google.com/p/pygeoip/issues/attachmentText?id=21&aid=210001000&name=__init__.py.patch&token=AQEwNUdjh1w6Tvx_pQvMUlaLMmA%3A1385844481406
- which looks like this https://pastebin.com/0BinS7r5
- I read this because I don't recall ever installing a patch locally into a dist-package
- http://stackoverflow.com/questions/16738175/applying-patch-to-standard-python-file-locally
- but thought I'd wait to hear if that looked correct.
- file location:
- /usr/local/lib/python2.7/dist-packages/pygeoip-0.3.0-py2.7.egg/pygeoip/__init__.py
- """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement