I am trying to use https://vpn-proxy-detection.ipify.org, and I can't get it to work. How do i get the value "vpn" inside "proxy"
req2 = requests.get(url = VPNLink + IP)
data3 = req2.json()
print(data3)
VPN = data3[""]
print(VPN)
Traceback (most recent call last):
File "c:\Users\Administrator\Desktop\VPNChecker.py", line 47, in <module>
VPN = data3["proxy.vpn"]
KeyError: 'proxy.vpn
This is the output from the API:
{"ip":"8.8.8.8","proxy":{"proxy":false,"vpn":false,"tor":false}}
You should make it like so:
VPN = data3["proxy"]["vpn"]
But be aware that when your program does network stuff, you have to look out for exceptions (e.g. server not found, server is down, KeyError if there's no proxy
or no vpn
).