我正在使用python中的请求库发出HTTP请求,但是我需要来自响应http请求的服务器的ip地址,并且我试图避免进行两次调用(并且可能有一个不同的ip地址来自响应的那个请求.
那可能吗?有没有python http库允许我这样做?
ps:我还需要发出HTTPS请求并使用经过身份验证的代理.
更新1:
例:
import requests
proxies = {
"http": "http://user:password@10.10.1.10:3128",
"https": "http://user:password@10.10.1.10:1080",
}
response = requests.get("http://example.org", proxies=proxies)
response.ip # This doesn't exist, this is just an what I would like to do
Run Code Online (Sandbox Code Playgroud)
那么,我想知道从响应中的方法或属性连接的IP地址请求.在其他库中,我能够通过找到sock对象并使用getpeername()方法来做到这一点.