Accessing Tor with Selenium in Python
To access the Tor browser using Selenium through Python you can use the following solution:
from selenium import webdriverfrom selenium.webdriver.firefox.firefox_profile import FirefoxProfileimport ostorexe = os.popen(r'C:\Users\AtechM_03\Desktop\Tor Browser\Browser\TorBrowser\Tor\tor.exe')profile = FirefoxProfile(r'C:\Users\AtechM_03\Desktop\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(firefox_profile= profile, executable_path=r'C:\Utility\BrowserDrivers\geckodriver.exe')driver.get("http://check.torproject.org")