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?
-
When you say "change servers", do you mean change to a new circuit? Or do you mean change a specific node? For example, a new entry (guard) node, or a new exit node? – Richard Horrocks Nov 15 '15 at 22:03
-
Which platform are you using? (Windows, Linux, Mac OS?) – Richard Horrocks Nov 15 '15 at 22:04
2 Answers
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.
- 344
- 1
- 12
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.
- 305
- 1
- 5