我尝试了很多次:
from tbselenium.tbdriver import TorBrowserDriver
with TorBrowserDriver("/path/to/TorBrowserBundle/") as driver:
driver.get('https://check.torproject.org')
*从这里; https://github.com/webfp/tor-browser-selenium
以我为
from tbselenium.tbdriver import TorBrowserDriver
with TorBrowserDriver("C:\Program Files (x86)\TOR\Tor Browser\Browser\firefox.exe") as driver:
driver.get('https://check.torproject.org')
但是,无法加载TOR:
tbselenium.exceptions.TBDriverPathError: TBB path is not a directory C:\Program Files (x86)\TOR\Tor Browser\Browser[image]irefox.exe
失败的“ [image]”是这样的:
https://imgur.com/LqwV3qv
为什么会变成这样?
最佳答案
Backslashes have special meaning on a str
。为了从字面上使用它们作为字符,您需要对它们进行转义:
from tbselenium.tbdriver import TorBrowserDriver
with TorBrowserDriver('C:\\Program Files (x86)\\TOR\\Tor Browser\\Browser\\firefox.exe') as driver:
driver.get('https://check.torproject.org')
关于python - 无法启动Tor浏览器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49987197/