【发布时间】:2021-03-07 19:46:04
【问题描述】:
我正在尝试使用 selenium 在 ubuntu 上使用 python 打开一个 Tor 浏览器窗口,然后对其进行控制,使其转到一个链接,输入一些组合键等。当我的代码打开 tor 时,它给了我一个弹出 “无法启动 tor,torrc 文件丢失,无法创建”,然后继续打开一个 tor 窗口,上面写着“等待 Tor 启动”。我什至还没有包含用于在网页上执行某些操作的其余代码,因为 tor 甚至不会一开始就打开。 Tor浏览器使用的文件夹和文件以及/etc/tor中的torrc文件(确实存在!)都对所有用户具有完全权限。这是我尝试运行的简单代码,但出现上述错误:
from selenium import webdriver
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
from selenium.webdriver.common.proxy import Proxy, ProxyType
from selenium.webdriver.firefox.options import Options
import os
binary = FirefoxBinary('/home/test/.local/share/torbrowser/tbb/x86_64/tor-browser_en-US/Browser/firefox')
driver = webdriver.Firefox(firefox_binary = binary)
driver.get("https://www.whatsmyip.org")
【问题讨论】:
标签: python selenium selenium-webdriver geckodriver tor