1
import socket
import socks
import urllib2
ipcheck_url = 'http://checkip.amazonaws.com/'
# Actual IP.
print(urllib2.urlopen(ipcheck_url).read())
# Tor IP.
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, '127.0.0.1', 9050)
socket.socket = socks.socksocket
print(urllib2.urlopen(ipcheck_url).read())

This actually works fine for me. But how do I come out of "setdefaultproxy" back to Actual IP. Because I still stuck in Tor IP I'm not able to get back to Actual IP. Some where I need to close the socket. How do I do that ?

This is with reference to : How to make urllib2 requests through Tor in Python?

1 Answer 1

1

You can set it back to the way is was like this:

socks.setdefaultproxy(None)
socket.socket = socks.socksocket
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.