Member-only story
Find IP address and location using python
In this article, we shall see how to fetch the IP address of the user using python with the help of the built-in requests module.
What is the request module in python?
The requests
module allows you to send HTTP requests like GET, POST, PUT and DELETE using Python. We are only going to use the get method to hit an url and get the response data
1. From “ipify.org”
The following url “https://api.ipify.org” returns the ip address of the user. This is how we execute the code in python.
But this url does not provide any additional information such as the address, state and country, etc of the user.
2. From “amazonaws.com”
Amazon AWS also provides us a way to fetch the IP address of the user using the url “https://checkip.amazonaws.com”. This will work even when connected to a VPN.