1

sorry if this is a dumb question, but I'm trying to figure out how to use Selenium to control Tor browser (which i understand is modified Firefox), but I can't find any instructions on how to do it on a system that also has regular Firefox and other browsers installed. I am using the following code but when the webdriver.Firefox() starts it opens a new non tor Firefox window, ending up with Tor Browser and Firefox running simultaneously, with Firefox indicating it under "remote control" not Tor.

How do I configure webdrivermanger to selectively call Tor or Firefox on demand?

from selenium import webdriver
from selenium.webdriver.firefox.service import Service
from webdriver_manager.firefox import GeckoDriverManager
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
import os

torexe = os.popen(r"/usr/bin/flatpak run com.github.micahflee.torbrowser-launcher")

profile = FirefoxProfile(r'/home/khan/.var/app/com.github.micahflee.torbrowser-launcher/data/torbrowser/tbb/x86_64/tor-browser/Browser/TorBrowser/Data/Browser/profile.default')
profile.set_preference('network.proxy.type', 1)
profile.set_preference('network.proxy.socks', '127.0.0.1')
profile.set_preference('network.proxy.socks_port', 9050)
profile.set_preference("network.proxy.socks_remote_dns", False)
profile.update_preferences()

driver = webdriver.Firefox(service=Service(GeckoDriverManager().install()))

driver.get("http://google.com")

PS: I'm on Linux Mint 21

Boni García
  • 4,618
  • 5
  • 28
  • 44
Saqster
  • 119
  • 1
  • 1
  • 8

0 Answers0