【问题标题】:Change proxy settings in Gecko Webbrowser at execution time?在执行时更改 Gecko Webbrowser 中的代理设置?
【发布时间】:2014-01-23 15:56:51
【问题描述】:

我想通过每次加载 X 页面和列表中的下一个代理来测试代理列表。

我正在使用 Gecko 网络浏览器 (GeckoFX),如何在网络浏览器控件执行时更改代理 IP:Port 以使用其他代理打开网页?

【问题讨论】:

    标签: c# .net vb.net browser gecko


    【解决方案1】:

    试试

    GeckoPreferences.Default["network.proxy.type"] = 1;
    GeckoPreferences.Default["network.proxy.http"] = proxyAddress.Host;
    GeckoPreferences.Default["network.proxy.http_port"] = proxyAddress.Port;
    GeckoPreferences.Default["network.proxy.ssl"] = proxyAddress.Host;
    GeckoPreferences.Default["network.proxy.ssl_port"] = proxyAddress.Port;
    

    【讨论】:

    • 嗨,抱歉打扰了这个话题...我测试了你的代码:pastebin.com/K1RiK10c 但是当我按下 Button1 时没有任何反应,表单不会向任何页面收费。 ://
    • @vmas 谢谢。 PS:你知道在geck webbrowser上代理连接失败时如何禁用代理警告消息框吗?
    • @ElektroStudios,您可以将“browser.xul.error_pages.enabled”设置为“true”(以显示不带MessageBox 的错误页面),或者您可以编写自己的PromptService 来抑制消息。
    【解决方案2】:

    我已经做了这个辅助方法:

    ''' <summary>
    ''' ProxyTypes of Gecko webbrowser.
    ''' </summary>
    Public Enum ProxyType
    
        ''' <summary>
        ''' Direct connection, no proxy. 
        ''' (Default in Windows and Mac previous to 1.9.2.4 /Firefox 3.6.4) 
        ''' </summary>
        DirectConnection = 0
    
        ''' <summary>
        ''' Manual proxy configuration.
        ''' </summary>
        Manual = 1
    
        ''' <summary>
        ''' Proxy auto-configuration (PAC).
        ''' </summary>
        AutoConfiguration = 2
    
        ''' <summary>
        ''' Auto-detect proxy settings.
        ''' </summary>
        AutoDetect = 4
    
        ''' <summary>
        ''' Use system proxy settings. 
        ''' (Default in Linux; default for all platforms, starting in 1.9.2.4 /Firefox 3.6.4)
        ''' </summary>
        System = 5
    
    End Enum
    
    ''' <summary>
    ''' Sets the proxy type of a Gecko Webbrowser.
    ''' </summary>
    ''' <param name="ProxyType">Indicates the type of proxy.</param>
    Private Sub SetGeckoProxyType(ByVal ProxyType As ProxyType)
    
        GeckoPreferences.Default("network.proxy.type") = ProxyType
    
    End Sub
    
    ''' <summary>
    ''' Sets the proxy of a Gecko Webbrowser.
    ''' </summary>
    ''' <param name="Host">Indicates the proxy host.</param>
    ''' <param name="Port">Indicates the proxy port.</param>
    Private Sub SetGeckoProxy(ByVal Host As String,
                              ByVal Port As Integer)
    
        ' Set the ProxyType to manual configuration.
        GeckoPreferences.Default("network.proxy.type") = ProxyType.Manual
    
        ' Set the HTP proxy Host and Port.
        GeckoPreferences.Default("network.proxy.http") = Host
        GeckoPreferences.Default("network.proxy.http_port") = Port
    
        ' Set the SSL proxy Host and Port.
        GeckoPreferences.Default("network.proxy.ssl") = Host
        GeckoPreferences.Default("network.proxy.ssl_port") = Port
    
    End Sub
    

    【讨论】:

      猜你喜欢
      • 2018-01-02
      • 1970-01-01
      • 2011-05-30
      • 2019-09-25
      • 1970-01-01
      • 1970-01-01
      • 2010-10-30
      相关资源
      最近更新 更多