Use Python Selenium through Tor
- Run
pip install -r requirements.txt - Open
path.txtand write absolute path to Tor Browser folder using single backslashes (\) - Open
router.pyand write Selenium code withinmain()function - Run
router.py!
- The
setup_tor()function contains the profile preferences for the Tor session. Modify these settings if necessary. They are implemented to ensure anonymity and default configuration changes. - However, if SOCKS port has changed for some reason (typically to
9151), here is where you would modify the port. - If some webpages are displaying improperly, this may be due to JavaScript being toggled off. Simply change
javascript.enabledtoTrue. Note that this may compromise anonymity. - If initializing Tor takes longer than Selenium, pass a delay time (in seconds) as a second parameter to the
setup_torfunction (eg.setup_tor(binary, 10))