干部官员docs说新身份是由以下几点确定的:
from stem import Signal
from stem.control import Controller
with Controller.from_port(port = 9051) as controller:
controller.authenticate()
controller.signal(Signal.NEWNYM)
以下是我的代码:
import urllib2
from stem import Signal
from stem.control import Controller
def connect():
with Controller.from_port(port=9051) as controller:
controller.authenticate(my_pass)
controller.signal(Signal.NEWNYM)
for i in range(5):
connect()
print urllib2.urlopen('http://icanhazip.com/').read().strip()
然而,IP地址不会改变。
PS。是的,我已编辑了torrc
文件。
有什么想法吗?
答案 0 :(得分:2)
你必须等到新的nym可用:
if controller.is_newnym_available():
controller.signal(Signal.NEWNYM)