简体   繁体   English

使用代理从 Firefox Geckodriver 浏览。 C#,硒

[英]Browsing from Firefox Geckodriver with proxy. C#, Selenium

using the code below i'm trying to set up Selenium to work with Geckodriver using custom ssl proxy.使用下面的代码,我正在尝试设置 Selenium 以使用自定义 ssl 代理与 Geckodriver 一起使用。

    FirefoxOptions options = new FirefoxOptions();
    Proxy proxy = new Proxy();
    proxy.SslProxy = "213.232.68.107:8000";
    options.Proxy = proxy;
    FirefoxDriver driver = new FirefoxDriver(options);

But, unfortunatly, it still uses direct connection, without any redirections.但是,不幸的是,它仍然使用直接连接,没有任何重定向。

Other way was to configure proxy using this part of code,另一种方法是使用这部分代码配置代理,

FirefoxProfile profile = new FirefoxProfile();         
profile.setPreference("network.proxy.type", 1);
profile.setPreference("network.proxy.http", "localhost");     
profile.setPreference("network.proxy.http_port", 3128); 

But, start of the browser failed with expection:但是,浏览器的启动失败了:

"The type initializer for 'System.IO.Compression.ZipStorer' threw an exception."

NotSupportedException: No data is available for encoding 437

No info was found about all of this stuff.没有找到关于所有这些东西的信息。 Any ideas?有任何想法吗?

Finally, managed to make it work just to switching from .net core into .net framework using this code最后,设法使其工作只是使用此代码从 .net 核心切换到 .net 框架

    FirefoxProfile profile = new FirefoxProfile();
    FirefoxOptions options = new FirefoxOptions();
    profile.SetPreference("network.proxy.type", 1);
    profile.SetPreference("network.proxy.http", "213.232.68.107");
    profile.SetPreference("network.proxy.http_port", 8000);
    options.Profile = profile;
    FirefoxDriver driver = new FirefoxDriver(options);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM