Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python pygeoip example

def geo(_file, _ip):
    ''' This function search the geolocation values of an IP address '''
    try:
        _geo = []
        geoDb = pygeoip.GeoIP(_file)
        ip_dictionary_values = geoDb.record_by_addr(_ip)
        ip_list_values = ip_dictionary_values.items()
        for item in ip_list_values:
            _geo.append({item[0]:item[1]})
        return _geo
    except:
        pass 
Source by www.programcreek.com #
 
PREVIOUS NEXT
Tagged: #python #pygeoip
ADD COMMENT
Topic
Name
6+3 =