Is it possible to use HTTPS proxy in HTMLunit?

醉酒当歌 提交于 2019-12-22 06:33:57

问题


I am new in HTMLunit and trying to set HTTPS proxy for HTMLunit. I tried to use https:// just before the HOST IP, but I got Exception.

Anyone can help me to solve this issue?


Update: My Code is:

 WebClient webClient = new  WebClient(BrowserVersion.FIREFOX_3_6,"https://199.127.100.13", 11888);

Update 2: I asked the developer team, The said that it is a bug in the framework. They will fix it.


回答1:


You should not be putting http:// or https:// behind the ip address of the proxy server.

If your http proxy server supports https then htmlunit would automatically use it. Here is an example of how to use proxy with htmlunit

For HTTP proxy

                ProxyConfig pc = new ProxyConfig();
                pc.setSocksProxy(false); //Set to false if it is a http server
                pc.setProxyHost("192.168.1.200"); //your proxy IP
                pc.setProxyPort(proxyPort);
                webClient.getOptions().setProxyConfig(pc);

and of course if you are using socks proxy than set the setSocksProxy to true.



来源:https://stackoverflow.com/questions/11689087/is-it-possible-to-use-https-proxy-in-htmlunit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!