We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9af637a commit 6ccf27dCopy full SHA for 6ccf27d
Python/CSV-IP-geolocation/IP_data.csv
@@ -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
Python/CSV-IP-geolocation/app.py
@@ -0,0 +1,15 @@
+import csv
+import requests
+
+with open("IP_data.csv") as csvfile:
+ 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