“Python Pygeoip Beispiel” Code-Antworten

Python Pygeoip Beispiel

pip install pygeoip
OSP PRO

Python Pygeoip Beispiel

>>> gi = pygeoip.GeoIP('GeoIPRegion.dat')
>>> gi.region_by_name('apple.com')
{'region_code': 'CA', 'country_code': 'US'}
OSP PRO

Python Pygeoip Beispiel

>>> gi = pygeoip.GeoIP('GeoIPISP.dat')
>>> gi.isp_by_name('cnn.com')
'Turner Broadcasting System'
OSP PRO

Python Pygeoip Beispiel

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 
OSP PRO

Python Pygeoip Beispiel

>>> gi = pygeoip.GeoIP('GeoIP.dat')
>>> gi.country_code_by_name('google.com')
'US'
>>> gi.country_code_by_addr('64.233.161.99')
'US'
>>> gi.country_name_by_addr('64.233.161.99')
'United States'
OSP PRO

Python Pygeoip Beispiel

>>> gi = pygeoip.GeoIP('GeoIPOrg.dat')
>>> gi.org_by_name('dell.com')
'Dell Computer Corporation'
OSP PRO

Python Pygeoip Beispiel

>>> gi = pygeoip.GeoIP('GeoIPASNum.dat')
>>> gi.asn_by_name('cnn.com')
'AS5662 Turner Broadcasting'
OSP PRO

Python Pygeoip Beispiel

$ wget -N http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
$ gunzip GeoLiteCity.dat.gz
OSP PRO

Python Pygeoip Beispiel

def coun(attackerip):
	ip_tocoun_db='GeoLiteCity.dat'
	gi = pygeoip.GeoIP(ip_tocoun_db) 
        # IP details are returend as a directory
	rec = gi.record_by_name(attackerip) 
	country = rec['country_name']
	country =str(country)
	return country 
OSP PRO

Python Pygeoip Beispiel

>>> import pygeoip
>>> gi = pygeoip.GeoIP('GeoIP.dat')
>>> gi.country_name_by_addr('64.233.161.99')
'United States'
OSP PRO

Ähnliche Antworten wie “Python Pygeoip Beispiel”

Fragen ähnlich wie “Python Pygeoip Beispiel”

Weitere verwandte Antworten zu “Python Pygeoip Beispiel” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen