We could scrape this page to get this information but fortunately, freegeoip.net gives us a convenient REST API to use. Scrolling further down the page, we can see the API documentation:
We can simply use the requests library to make a GET request using the properly formatted URL. As an example, just entering the following URL in the browser returns a JSON representation of the geocoded data for the given IP address:
A Python script to demonstrate this is available ...