import requests
# 测试函数
#{"ip":"123.4.231.114","locale":""}
url = 'http://ip.hahado.cn/ip'
proxy = {'http':'http://H1U0P72S1427R2NC:7929A07B5CAEAA72@http-cla.abuyun.com:9030'}
response = requests.get(url=url,proxies=proxy)
print(response.text)
{"ip":"113.121.73.118","locale":""}
说明 proxy = {'http':'http://通行证书:通行密钥@HTTP隧道服务器地址:端口'}
获得本机外网ip地址
http://ip.hahado.cn/ip

本文介绍了一种通过Python的requests库结合代理服务器获取本机公网IP地址的方法。演示了如何设置代理并发起GET请求,从指定URL 'http://ip.hahado.cn/ip' 获取IP信息。
856

被折叠的 条评论
为什么被折叠?



