Ejemplo n.º 1
0
from nose.tools import *
import pyipinfodb
import secrets

apikey = secrets.apikey
i = pyipinfodb.IPInfo(apikey)

def test_country():
    ideal = {
        u'countryName': u'United States',
        u'ipAddress': u'155.33.148.202',
        u'countryCode': u'US',
        u'statusMessage': u'',
        u'statusCode': u'OK'
    }
    test = i.get_country('155.33.148.202')
    assert_equal(ideal, test)

def test_city():
    ideal = {u'cityName': u'Mountain View',
         u'countryCode': u'US',
         u'countryName': u'United States',
         u'ipAddress': u'8.8.8.8',
         u'latitude': u'37.406',
         u'longitude': u'-122.079',
         u'regionName': u'California',
         u'statusCode': u'OK',
         u'statusMessage': u'',
         u'timeZone': u'-07:00',
         u'zipCode': u'94043'
    }
Ejemplo n.º 2
0
n = 10
while n > 0:
    print(n)
    n = n - 1
print('Blastoff!')

import pyipinfodb

ip_lookup = pyipinfodb.IPInfo(
    '877d192cdb8b0543b679dd6e5c2bd6e48c55016aaf6844f6495f1f7772b801d4')
ip_lookup.get_country('8.8.8.8')

from requests import get

loc = get('https://ipapi.co/json/').text
print(loc)

import socket

socket.gethostbyname(socket.gethostname())

g = "Golf"
h = "Hotel"
print('% and %') % (g, h)
Ejemplo n.º 3
0
def getIPInfo(ip):
    ip_lookup = pyipinfodb.IPInfo(Config.API_KEY_IPINFODB)
    res= ip_lookup.get_country(ip)
    return res['countryCode']
Ejemplo n.º 4
0
import json
import numpy as np
import pyipinfodb
import time

ip_lookup = pyipinfodb.IPInfo('API_KEY_HERE')


with open('ips.txt','r') as f:
	for line in f.readlines():
		print "Getting location for %s" % line 
		req=ip_lookup.get_city(line)
		time.sleep(0.5)
		with open('geo.txt', 'ab') as geo:
			geo.write('%s,%s\n' % (req['longitude'], req['latitude']))