“Contoh Python Pygeoip” Kode Jawaban

Contoh Python Pygeoip

pip install pygeoip
OSP PRO

Contoh Python Pygeoip

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

Contoh Python Pygeoip

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

Contoh Python Pygeoip

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

Contoh Python Pygeoip

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

Contoh Python Pygeoip

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

Contoh Python Pygeoip

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

Contoh Python Pygeoip

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

Contoh Python Pygeoip

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

Contoh Python Pygeoip

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

Jawaban yang mirip dengan “Contoh Python Pygeoip”

Pertanyaan yang mirip dengan “Contoh Python Pygeoip”

Lebih banyak jawaban terkait untuk “Contoh Python Pygeoip” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya