I've been using python to interact with Tor and Stem.
And on line controller.signal(Signal.NEWNYM)
in the code it's always marking Signal
with the error
Instance of 'Enum' has no 'NEWNYM' memberpylint(no-member)
I have no idea why its doing this. This particular section of code is what the official Stem website uses to change IP address.
I have also turned pylint
off at one point but that means i can't see typos easily.
Every "fix" just makes all error checking go, is it a bug with the stem library?
My IDE is VScode
and I'm working in Python 3.6.9 64bit
on Ubuntu if that helps.
import requests
import time
from stem import Signal
from stem.control import Controller
def get_current_ip():
session = requests.session()
# TO Request URL with SOCKS over TOR
session.proxies = {}
session.proxies['http']='socks5h://localhost:9050'
session.proxies['https']='socks5h://localhost:9050'
try:
r = session.get('http://httpbin.org/ip')
except Exception as e:
print(e)
else:
return r.text
def renew_tor_ip():
with Controller.from_port(port = 9051) as controller:
controller.authenticate()
controller.signal(Signal.NEWNYM)
if __name__ == "__main__":
for i in range(4):
print(get_current_ip())
renew_tor_ip()
time.sleep(5)