我想使用 Tor 浏览器来绕过审查,但使用 Firefox 配置文件和 Tor 守护程序不起作用。这是我的代码:
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")
浏览器快照: doesn't work
并且普通网站无法打开并且只能加载。 我从here获取代码.
最佳答案
实际上,您应该将 sock_port 更改为 9150。
关于python - 使用 Firefox 配置文件和 tor 守护程序不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59510020/