9

I'm trying to build a bot but I need it that Tor will change servers every time I refresh the page. I could also use one if I get to manually change it using a command line. Any suggestions?

2 Answers2

2

Yes you can. I recommend using Stem to control your tor circuit. Hopefully that points you in the right direction. The link also has a menu with tutorials at the top that have some great examples to get used to using it. Good luck with your bot, I've made a few for Tor so I know it can be done.

james-see
  • 344
  • 1
  • 12
1

Yes. You can use stem.

Assuming your Tor control port is 9051 and no cookie or password is needed, the following code will initialize a controller object.

import stem
import stem.control
controller=stem.control.Controller.from_port()
controller.authenticate()

Then, each time you want a new circuit, you can use

controller.signal(stem.Signal.NEWNYM)

By default, Tor will only establish a new circuit in this way at most every 10 seconds. If you want to have new circuits more frequently, you will need to changed the source code. MAX_SIGNEWNYM_RATE means the interval in seconds (although its name suggests the rate) at which it will accept the signal NEWNYM.

v7d8dpo4
  • 305
  • 1
  • 5