How to change Tor identity in Python?

前端 未结 6 2280
南旧
南旧 2020-11-28 19:14

I have the following script:

import socks
import socket
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, \"127.0.0.1\", 9050)
socket.socket = socks.socksocket
         


        
6条回答
  •  天命终不由人
    2020-11-28 19:55

    You can enable tor control server by uncommenting few lines in

    /etc/tor/torrc
    

    And use stem library to send NEWNYM signal to change circuit.

    controller.signal(Signal.NEWNYM)
    

    You can read tutorial here.

提交回复
热议问题