How to get and change Public IP in Python?
I have been trying to get the live IP address in python and change it using a proxy server. The code I have seen is for local IP not the Public IP.
How can I get public IP using python? i.e. the IP I get from whatismyip, and can change the public IP using a proxy request in Python on windows.
There are multiple services you can use to get your ip. The one I use mostly is ipinfo.io/ip
You can use below code
import requests
proxies = {
'http': 'http://<IP>:<PORT>',
'https': 'http://<IP>:<PORT>',
}
req = requests.get('http://ipinfo.io/ip', proxies=proxies)
print (req.text)