问题
I want to use tor browser to bypass censorship but using the Firefox Profile and the tor daemon doesn't work. here's my code:
from selenium import webdriver
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
import os
torexe = os.popen(r'C:\Users\fathollahy\Desktop\Tor Browser\Browser\TorBrowser\Tor\tor.exe')
profile = FirefoxProfile(r'C:\Users\fathollahy\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'geckodriver.exe')
driver.get("http://check.torproject.org")
Browser Snapshot: doesn't work
and normal sites don't open and just loading. I got the code from here.
回答1:
Actually, You should change the sock_port to 9150.
来源:https://stackoverflow.com/questions/59510020/using-the-firefox-profile-and-the-tor-daemon-doesnt-work