'How to find location using ip address [closed]
I have my site hosted on pythonanywhere.com and I can get my site visitor's ip address from access log. my question is
- Is it possible to get exact location of that visitor ?
Solution 1:[1]
You can get the location of your visitor from its IP address. This is a process called geolocation.
Since you need to get the exact location, you must know that its accuracy depends on multiple factors, and all geolocation APIs are not equally accurate. I managed to get the best result with Abstract API (it has free and commercial plans). You query it with a get request, and you receive a JSON response with latitude, longitude, country, city...
AS the comment under your question states, some visitors can hide their real IP by using a VPN service, and among the JSON response, this API can tell you if the IP belongs to a VPN service, so you know if the visitor was hiding his location and IP.
Solution 2:[2]
You can use some API service for that.
For example, the https://apiip.net , their API provides a lot of info about the IP, also you can request XML responses if needed.
Simple GET call:
https://apiip.net/api/check?ip=67.250.186.196&accessKey={your_api_key}
The response:
{
"ip": "67.250.186.196",
"continentCode": "NA",
"continentName": "North America",
"countryCode": "US",
"countryName": "United States",
"countryNameNative": "United States",
"city": "New York",
"postalCode": "10001",
"latitude": 40.8271,
"longitude": -73.9359,
"capital": "Washington D.C.",
"phoneCode": "1",
"countryFlagEmoj": "??",
"countryFlagEmojUnicode": "U+1F1FA U+1F1F8",
"isEu": false,
"languages": {
"en": {
"code": "en",
"name": "English",
"native": "English"
}
},
"currency": {
"code": "USD",
"name": "US Dollar",
"symbol": "$",
"number": "840",
"rates": {
"EURUSD": 1.11
}
},
"timeZone": {
"id": "America/New_York",
"currentTime": "10/26/2021, 2:54:10 PM",
"code": "EDT",
"timeZoneName": "EDT",
"utcOffset": -14400
},
"connection": {
"asn": 12271,
"isp": "Charter Communications Inc"
},
"security": {
"isPublicProxy": false,
"isResidentialProxy": false,
"isTorExitNode": false,
"network": "67.250.176.0/20"
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Benj |
| Solution 2 |
