I'm currently using tor to wrap my http requests in python, my code looks like so:
import requests
import socks
import socket
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS4, '127.0.0.1', 9050, True)
socket.socket = socks.socksocket
def is_up_or_down(url):
try:
response = requests.get(url)
except requests.exceptions.ConnectionError:
return {"response_code":404, "elapsed_time":0}
return {"response_code":response.status_code, "elapsed_time":response.elapsed.total_seconds()}
Right now I have it returning the status code of the request and the elapsed time, but is it possible to get the IP that was used to make the request?
EDIT: To be clear, I want to see which IP I'm using to make the request that way I'll know if my proxy is working or not.