1

I tried to use api of this site(https://ipstack.com/) and wrote code bellow:

r = requests.get(r'http://api.ipstack.com/check?access_key=key')
j = json.loads(r.text)
lat = j['latitude']
lon = j['longitude']
print(lat, lon)

This code gives me wrong location, it right defines city, but area is invalid. How can i get my real location?

Ymka
  • 81
  • 8

1 Answers1

0

Seems to work fine here, though you might want to change the way you parse the response:

import requests
r = requests.get(r'http://api.ipstack.com/check?access_key=key')
j = r.json()
lat = j['latitude']
lon = j['longitude']
print(lat, lon)
print(j)
Ymka
  • 81
  • 8
Gijs Wobben
  • 1,974
  • 1
  • 10
  • 13
  • 1
    I don't know what exotic location you're in, but I think you have to ask the people from ipstack. It's not a code related issue. – Gijs Wobben Nov 20 '20 at 08:44
  • @GijsWobben, do u know any another way to get location using python? – Nikto Nov 20 '20 at 08:47
  • Google maps? https://medium.com/@n0tty/tracking-any-user-location-with-ip-address-using-google-api-9b58d8c62f89 – Gijs Wobben Nov 20 '20 at 08:54
  • @GijsWobben, i got another question. signalToNoiseRatio: The current signal to noise ratio measured in dB. signalStrength: The current signal strength measured in dBm. Data: Signal : 100% ', ' Radio type : 802.11n', Basic rates (Mbps) : 1 2 5.5 11', ' Other rates (Mbps) : 6 9 12 18 24 36 48 54' How can i pull signalStrength and signalToNoiseRatio from my data? – Nikto Nov 20 '20 at 11:58
  • Please post any new questions as new question in Stack Overflow. – Gijs Wobben Nov 20 '20 at 13:01