1

Trying to connect to tor via selenium for the first time. Using Windows 7 64 ...Getting this error code..

selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 0

and a pop-up saying tor failed to start. Here is my code.

from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
binary = FirefoxBinary(r'C:\Users\Abhi\Desktop\Tor Browser\Browser\firefox.exe')
torexe = os.popen(r'C:\Users\Abhi\Desktop\Tor Browser\Browser\TorBrowser\Tor\tor.exe')
profile = FirefoxProfile(r'C:\Users\Abhi\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', 9150)
profile.set_preference("network.proxy.socks_remote_dns", False)
profile.update_preferences()
driver = webdriver.Firefox(firefox_profile= profile, executable_path=r'C:\Users\Abhi\Desktop\geckodriver.exe', firefox_binary=binary)
driver.get("http://check.torproject.org")

Any help is appreciated.Thanks guys.

1 Answer 1

0

You need to have tor browser running before hand .

This will connect via tor and load your profile so that google,FB etc opens with you already logged in. This is working as of today on win7 64 bit.

from selenium import webdriver
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
binary = FirefoxBinary("C:\\Program Files\\Mozilla Firefox\\firefox.exe")
profile = FirefoxProfile("C:\\Users\\user\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\ogwfse3l.default-release")
profile.set_preference('network.proxy.type', 1)
profile.set_preference('network.proxy.socks', '127.0.0.1')
profile.set_preference('network.proxy.socks_port', 9150)
driver = webdriver.Firefox(firefox_profile=profile, firefox_binary=binary, executable_path="C:\\geckodriver.exe")
driver.maximize_window()
driver.get('https://www.gmail.com')

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .