<p>我通过更新到v9.5.1并实施以下更改,成功地解决了这一问题:</p>
<p><em>请注意,尽管代码是C语言,但对Tor浏览器及其启动方式的相同更改也应适用</em></p>
<pre><code>FirefoxProfile profile = new FirefoxProfile(profilePath);
profile.SetPreference("network.proxy.type", 1);
profile.SetPreference("network.proxy.socks", "127.0.0.1");
profile.SetPreference("network.proxy.socks_port", 9153);
profile.SetPreference("network.proxy.socks_remote_dns", false);
FirefoxDriverService firefoxDriverService = FirefoxDriverService.CreateDefaultService(geckoDriverDirectory);
firefoxDriverService.FirefoxBinaryPath = torPath;
firefoxDriverService.BrowserCommunicationPort = 2828;
var firefoxOptions = new FirefoxOptions
{
Profile = null,
LogLevel = FirefoxDriverLogLevel.Trace
};
firefoxOptions.AddArguments("-profile", profilePath);
FirefoxDriver driver = new FirefoxDriver(firefoxDriverService, firefoxOptions);
driver.Navigate().GoToUrl("https://www.google.com");
</code></pre>
<p>重要提示:</p>
<p>需要在关于:配置的<strong>中更改以下TOR配置:</p>
<ul>
<li><p><strong>木偶。已启用</strong>:真</p>
</li>
<li><p><strong>木偶网.port</strong>:设置为未使用的端口,并在代码中将此值设置为<strong>firefoxDriverService.BrowserCommunicationPort</strong>。在我的示例中,该值设置为2828</p>
</li>
</ul>