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? ie 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)
import hek
# get ip
ip = hek.ipstuff.myip(find="query")
# print ip
print(ip)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.