Want to award this author with Pubby Cash? You must log in first!

Mapping IP addresses to Geographic Locations in Python

Categories: Tech | Pubby Cash Received:  10 | Click to Award

An IP address - a list of four segments of 3 digits numbers between 0 and 255 and connected by dots can contain more information than you think. Underneath this article, you can see where this article is posted from. This gives you an example that an IP address can be transformed to the geographical location. I'm introducing one way to realize it in Python - use API from ipinfo.io. Their free version can give the geographic location, ISP provider's name, and even GPS coordinates of the location, which should be enough for most website owners. Their API include a token, which is good for querying 50,000 times a month. The following code can be used as an example. Remember to replace the ip and token with your ip and token. import requests, json link = f'https://ipinfo.io/{ip}?token={token}' r = requests.get(link) content = json.loads(r.content) print(content)


Published from: Pennsylvania US
Liked by: Andy Tang, Evan Tang, fnfOzvSR 

Daily Deals


MECHANICSBURG WEATHER