gpt4 book ai didi

python - 无法启动Tor浏览器

转载 作者:行者123 更新时间:2023-12-01 01:57:36 34 4
gpt4 key购买 nike

我尝试了很多次:

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/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com