Is it possible to use HTTPS proxy in HTMLunit?

2019-05-01 19:17发布

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条回答
疯言疯语
2楼-- · 2019-05-01 20:00

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.

查看更多
登录 后发表回答