Skip to content

Instantly share code, notes, and snippets.

@AstinCHOI
Created December 21, 2020 10:33
Show Gist options
  • Save AstinCHOI/180f5f45e8f208446ec91f7f5a8bb38f to your computer and use it in GitHub Desktop.
Save AstinCHOI/180f5f45e8f208446ec91f7f5a8bb38f to your computer and use it in GitHub Desktop.
Get IP Geo Location
from ip2geotools.databases.noncommercial import DbIpCity
import collections
countries = []
with open("IP.csv") as f:
while True:
line = f.readline()
if not line:
break
print(line.strip()[1:-1])
try:
response = DbIpCity.get(line.strip()[1:-1], api_key='free')
countries.append(response.country)
except:
pass
print(collections.Counter(countries))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment