Open ice1x opened 6 years ago
from stem import Signal from stem.control import Controller import socks, socket
with Controller.from_port(port=9051) as controller: controller.authenticate("your hash password") controller.signal(Signal.NEWNYM)
SOCKS_PORT = 9050 # TOR proxy port that is default from torrc, change to whatever torrc is configured to socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", SOCKS_PORT) socket.socket = socks.socksocket
def getaddrinfo(*args): return [(socket.AF_INET, socket.SOCK_STREAM, 6, '', (args[0], args[1]))]
socket.getaddrinfo = getaddrinfo
Add these above lines to your script after installing tor and you're good to go
I still not able to launch Tor automatically. Tor should be launched manually before the script, something related to port number or something like that.