Python Selenium与Tor浏览器7.x绑定

时间:2017-06-18 06:35:26

标签: python selenium tor

我需要你的帮助才能在Windows上使用Tor Browser + Python Selenium进行自动化。

我正在使用带有Tor Browser 7.0.1的selenium 3.4.3,初始化TOR Web驱动程序的代码如下

    binary = FirefoxBinary(TOR_BINARY_PATH)
    prof = FirefoxProfile(TOR_PROFILE_PATH)

    prof.set_preference('network.proxy.type', 1)
    prof.set_preference('network.proxy.socks_host', '127.0.0.1')
    prof.set_preference('network.proxy.socks_port', 9150)
    prof.update_preferences()

    self.browser = webdriver.Firefox(firefox_profile=prof, firefox_binary=binary)

但是,我坚持错误&#Tor;未能启动'每次我运行脚本。

1 个答案:

答案 0 :(得分:0)

您需要启动Tor浏览器,或在运行脚本之前建立Tor连接。您可以通过在终端中运行Tor,或者只是启动Tor浏览器

来实现