2017-04-08 6 views
0

こんにちは、私はいくつかのブログで見つかったこのコードを実行するといくつかの要求の後に私のIPを変更しようとしてきました。 2つの出力で同じです。誰かが私が間違っていることの手がかりを持っていますか?私のIPを変更できないのはなぜですか? Tor&Python

from stem import Signal 
from stem.control import Controller 
import requests 

def set_new_ip(): 
    """Change IP using TOR""" 
    with Controller.from_port(port=9051) as controller: 
     controller.authenticate(password='my_password') 
     controller.signal(Signal.NEWNYM) 

local_proxy = '127.0.0.1:8118' 
http_proxy = {'http://': local_proxy, 
      'https://': local_proxy} 

current_ip = requests.get(url='http://icanhazip.com/', 
         proxies=http_proxy, 
         verify=False) 

print(current_ip.text) 

set_new_ip() 

current_ip = requests.get(url='http://icanhazip.com/', 
         proxies=http_proxy, 
         verify=False) 

print(current_ip.text) 

答えて

関連する問題