【问题标题】:Port 9050 is not listening端口 9050 未在监听
【发布时间】:2020-01-03 05:18:45
【问题描述】:

我想使用 tbselenium 包进行浏览器自动化,但是当我尝试运行代码时出现以下错误 TBDriverPortError: SOCKS port 9050 is not listener.

以下是我用过的代码sn-p。

import unittest
from time import sleep
from tbselenium.tbdriver import TorBrowserDriver
import tbselenium.common as cm


class TestSite(unittest.TestCase):
    def setUp(self):
        # Point the path to the tor-browser_en-US directory in your system
        tbpath = r'C:\Users\Sachin\Desktop\Tor Browsernew'
        self.driver = TorBrowserDriver(tbpath, tbb_logfile_path='test.log')
        self.url = "https://check.torproject.org"

    def tearDown(self):
        # We want the browser to close at the end of each test.
        self.driver.close()

    def test_available(self):
        self.driver.load_url(self.url)
        # Find the element for success
        element = self.driver.find_element_by_class_name('on')
        self.assertEqual(str.strip(element.text),
                         "Congratulations. This browser is configured to use Tor.")
        sleep(2)  # So that we can see the page


if __name__ == '__main__':
    unittest.main()

谁能帮我解决这个错误已经苦苦挣扎了好几天了

【问题讨论】:

  • 嗨 sachin,端口 9050 是我在 google 上找到的 Versiera Agent Listener。您是否尝试使用任何其他端口并发现相同的问题?
  • 嗨@RaHuL实际上我需要专门使用tor浏览器,它只使用端口9050,所以浏览器打开但没有响应的其他端口
  • 尝试关闭防火墙并尝试相同。有时防火墙会阻止该端口。谢谢
  • 您需要从 Torrc 文件中取消注释 ControlPortHashedControlPasswordCookieAuthentication
  • 你的 torrc 文件必须是 github.com/torproject/tor/blob/master/src/config/… 这样的内容,或者你可以手动粘贴。你用的是哪个操作系统?

标签: python python-3.x selenium web-scraping tor


【解决方案1】:

您需要从 Torrc 文件中取消注释 ControlPortHashedControlPasswordCookieAuthentication

你可以从here获取torrc

然后重新加载 Tor 服务。

如果您遇到问题,请在问题中发布完整的引用

【讨论】:

  • 我可以使用 ypu 方法连接到 tor,但一个问题仍然存在,我想使用 tor 包中的 firfox 应用程序,但这是使用普通的 firfox,因此我无法使用我们的出口节点虽然我已经在 torrc 中提到了出口节点
  • 您的解决方案很有效,但对国家出口节点有任何帮助
  • 你可以从这里指定退出节点b3rn3d.herokuapp.com/blog/2014/03/05/tor-country-codes
  • 如果你得到解决方案,请点击右勾并投票给其他人从这个问题中获得帮助
猜你喜欢
  • 2021-12-16
  • 1970-01-01
  • 2017-09-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-07-12
  • 2012-03-18
相关资源
最近更新 更多