每次我试图用selenium开始时Tor都会崩溃,Python:请不要删除我的问题,另一个问题只有C语言的答案#

2024-05-28 19:15:56 发布

您现在位置:Python中文网/ 问答频道 /正文

每次我想运行我的程序时都会崩溃。代码没有错误。路径都是正确的。这是我的密码:

from selenium import webdriver
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
import os

torexe = os.popen(r'C:/Users/Seya Fässler/Desktop/Tor Browser/Browser/TorBrowser/Tor/tor.exe')
profile = FirefoxProfile(r'C:/Users/Seya Fässler/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()


firefox_options = webdriver.FirefoxOptions()
firefox_options.binary_location = r'C:/Users/Seya Fässler/Desktop/Tor Browser/Browser/firefox.exe'
driver = webdriver.Firefox(firefox_profile= profile, options = firefox_options, executable_path=r'C:/Users/Seya Fässler/Webdrivers/geckodriver.exe')
driver.get("https://www.apple.com")

之后,将显示此警报:

Tor Alert

当我按OK时,它会打开此窗口,我无法复制日志,因为它有0行

Tor Alert 2

我使用Windows 10,作为使用anaconda的环境,tor浏览器是最新版本(9.5.3),我使用Python 3.8.3。 请不要因为重复而删除我的问题,另一个问题有答案,但只有C#的答案,而且它不适用于python 谢谢


Tags: importbrowsernetworkfirefoxprofileuserstorproxy

热门问题