【问题标题】:Trying to connect to tor with python3尝试使用 python3 连接到 tor
【发布时间】:2023-03-07 07:40:01
【问题描述】:

我一直在尝试在 Mac 上使用 python 连接到 tor。如果有帮助,我有 python3 和 Mac Mojave。我的代码是:

import stem.process
from stem import Signal
from stem.control import Controller
from splinter import Browser

proxyIP = "127.0.0.1"
proxyPort = 9150

proxy_settings = {"network.proxy.type":1,
    "network.proxy.ssl": proxyIP,
    "network.proxy.ssl_port": proxyPort,
    "network.proxy.socks": proxyIP,
    "network.proxy.socks_port": proxyPort,
    "network.proxy.socks_remote_dns": True,
    "network.proxy.ftp": proxyIP,
    "network.proxy.ftp_port": proxyPort
}
browser = Browser('firefox', profile_preferences=proxy_settings)
browser.visit("http://www.icanhazip.com")

但是,每当我运行它时,就会发生错误:

Traceback (most recent call last):
  File "test.py", line 27, in <module>
    browser = Browser('firefox', profile_preferences=proxy_settings)
  File "/usr/local/lib/python3.6/site-packages/splinter/browser.py", line 64, in Browser
    return driver(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/splinter/driver/webdriver/firefox.py", line 78, in __init__
    **kwargs
  File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/firefox/webdriver.py", line 174, in __init__
    keep_alive=True)
  File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: Unable to find a matching set of capabilities

任何帮助将不胜感激。问候,泰勒

【问题讨论】:

  • 这是你的 geckodriver 版本导致的,你的 selenuim 版本和 geckodriver 版本是什么

标签: python-3.x python-requests tor


【解决方案1】:

我不知道你的 selenium 版本和 geckodriver 版本,所以我可以回答是upgrade them

pip install -U selenium

here下载最新版本的geckodriver

【讨论】:

    猜你喜欢
    • 2014-09-22
    • 1970-01-01
    • 1970-01-01
    • 2021-10-07
    • 1970-01-01
    • 2015-04-08
    • 2018-11-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多