Skip to content

Commit 6ccf27d

Browse files
committed
initial commit and added csv IP geolocation
1 parent 9af637a commit 6ccf27d

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Service,IP
2+
Google,216.58.203.14
3+
Yahoo,98.137.11.164
4+
Facebook,31.13.79.35
5+
LinkedIn,108.174.10.10

Python/CSV-IP-geolocation/README.md

Whitespace-only changes.

Python/CSV-IP-geolocation/app.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import csv
2+
import requests
3+
4+
with open("IP_data.csv") as csvfile:
5+
reader = csv.DictReader(csvfile)
6+
for row in reader:
7+
ip_address = row['IP']
8+
api_url = "http://ip-api.com/json/" + ip_address
9+
response = requests.get(api_url).json()
10+
11+
city = response['city']
12+
state = response['regionName']
13+
country = response['country']
14+
15+
print(f"{ip_address} => {city}, {state}, {country}")

0 commit comments

Comments
 (0)