首页 > 解决方案 > 端口 9050 Not Listening tb selenium

问题描述

我想在 linux mint 机器上使用 tbselenium 包进行浏览器自动化。当我尝试运行应该可以工作的代码时,python 会给我错误消息:

tbselenium.exceptions.TBDriverPortError: SOCKS port 9050 is not listening

我试图使用的代码是:

from tbselenium.tbdriver import TorBrowserDriver
import time
with TorBrowserDriver("/home/sas/Videos/tor-browser_en-US/") as driver:
    driver.get("https://github.com/mozilla/geckodriver")



有谁知道为什么会这样?答案已公布:)

编辑:我唯一开放的端口是 5060

标签: pythonseleniumtor

解决方案


在运行这个“基本用法”示例(https://github.com/webfp/tor-browser-selenium)时,我遇到了同样的问题(SOCKS port 9050 is not listening):

from tbselenium.tbdriver import TorBrowserDriver
with TorBrowserDriver("/path/to/TorBrowserBundle/") as driver:
    driver.get('https://check.torproject.org')

以下命令修复了该问题:

sudo service tor restart

推荐阅读