c# - 关于 tor selenium C#
问题描述
大家好,我尝试在 C# 中使用 tor 我在网站上找到了一些资源,但我有一些问题请帮助我:
WebDriverWait Wait;
IWebDriver Driver;
String torBinaryPath = @"D:\Tor Browser\Browser\firefox.exe";
Process TorProcess = new Process();
TorProcess.StartInfo.FileName = torBinaryPath;
TorProcess.StartInfo.Arguments = "-n";
TorProcess.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
TorProcess.Start();
FirefoxProfile profile = new FirefoxProfile();
profile.SetPreference("network.proxy.type", 1);
profile.SetPreference("network.proxy.socks", "127.0.0.1");
profile.SetPreference("network.proxy.socks_port", 9150);
FirefoxOptions options = new FirefoxOptions();
options.Profile = profile;
Driver = new FirefoxDriver(options);
Wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(60));
Driver.Navigate().GoToUrl(@"http://whatismyipaddress.com/");
问题是在此处输入图像描述
解决方案
您需要使用选项而不是配置文件。请检查下面的示例。
FirefoxOptions opt = new FirefoxOptions();
opt.Profile = new FirefoxProfile();
opt.Profile.SetPreference("network.proxy.type", 1);
opt.Profile.SetPreference("network.proxy.socks", "127.0.0.1");
opt.Profile.SetPreference("network.proxy.socks_port", 9150);
this.Driver = new FirefoxDriver(opt);
推荐阅读
- java - How to login two user types (like admin and user) using single login activity in SQLite Android?
- c# - App opens console window when being build with Docker
- r - Strange behaviour when ggplotting line thickness depending on field of a sf "MULTILINESTRING"
- node.js - Gupshup whatsApp api 在收到 webhook 后返回 200 时发送“ok”消息
- python - Reshaping Data with Python
- java - 没有@JoinTable 的 Spring Boot Hibernate @ManyToMany 关联
- java - DynamoHttpServletRequest.getRemotePort() 返回 0 如何获取客户端 Remort Port
- c# - 即时窗口中 LINQ Select() 的 C# 异常,但编译时相同的代码有效
- kotlin - Kotlin Js 文件太大
- google-bigquery - 大查询 - 提取包含表情符号的 json 字段?