Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use HTTPS proxy in HTMLunit?

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.

like image 660
Saeed Zareian Avatar asked Nov 14 '22 01:11

Saeed Zareian


1 Answers

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.

like image 174
Arya Avatar answered Dec 25 '22 20:12

Arya