Python Version : 3.5.1
requests version: 2.9.1.
I am trying to get the IP address of url in python's request like below as explained here: How do I get the IP address from a http request using the requests library?
import requests
rsp = requests.get('http://google.com', stream=True)
# grab the IP while you can, before you consume the body!!!!!!!!
print (rsp.raw._fp.fp._sock.getpeername())
# consume the body, which calls the read(), after that fileno is no longer available.
print (rsp.content)
Getting below error:
AttributeError: '_io.BufferedReader' object has no attribute '_sock'
May be some version issues. Please help.
P.S. Unable to comment in original post.