API Websites:
- Ipify – External IP Address – https://www.ipify.org
- IP-API – Geolocation from IP Address – https://ip-api.com/
Code:
This code will get your external IP Address, and then use that to find geographic information.
import requests
ip_address = requests.get('http://api.ipify.org').text
print(ip_address)
response = requests.get(f'http://ip-api.com/json/{ip_address}').json()
print(response)
print(response['city'])
Be the first to comment