【问题标题】:Open onion links using selenium (python)使用硒打开洋葱链接(python)
【发布时间】:2022-12-21 23:14:38
【问题描述】:

我正在尝试使用 selenium (python3) 打开 .onion 链接。但是我遇到了同样的错误:

selenium.common.exceptions.WebDriverException: Message: Reached error page: about:neterror?e=dnsNotFound

这是我的代码的一部分。

options = Options()
options.set_preference('profile', '<path>/Browser/TorBrowser/Data/Browser/profile.default')

options.set_preference('network.proxy.type', 1)
options.set_preference('network.proxy.socks', '127.0.0.1')
options.set_preference('network.proxy.socks_port', 9050)
options.set_preference('network.proxy.socks_remote_dns', False)


driver = webdriver.Firefox(service=Service(GeckoDriverManager().install()), options=options)


driver.get('<link>.onion/auth/login')

我在 Ubuntu 21.10 上。在 firefox 中转到 127.0.0.1:9050 会提供 tor 已启动的信息

更新: 如果我尝试打开 tor 连接检查:

driver.get('http://check.torproject.org')
print(driver.find_element(By.TAG_NAME, 'h1').text) 

我得到结果: Congratulations. This browser is configured to use Tor 所以我认为问题出在 Onion 链接和 get() 方法上

【问题讨论】:

  • 请阐明您的具体问题或提供更多详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。

标签: python python-3.x selenium proxy tor


【解决方案1】:

您需要将远程 dns 设置为 true,所以只需替换它:

options.set_preference('network.proxy.socks_remote_dns', False)

对此:

options.set_preference('network.proxy.socks_remote_dns', True)

您将能够打开 .onion 链接。

【讨论】:

    猜你喜欢
    • 2011-10-09
    • 1970-01-01
    • 2014-10-15
    • 1970-01-01
    • 1970-01-01
    • 2015-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多