I want to use HtmlUnit with Tor. But I canβt connect to Tor using HtmlUnit (I have the Tor browser package running). I read in the TOR documentation that I can use Tor with other applications using the socks proxy on localhost: 9050.
I can connect to regular proxies found on Google with this code:
WebClient webClient = new WebClient(); ProxyConfig prc = new ProxyConfig("xxx.xxx.xxx.xxx", 8081, false); webClient.getOptions().setProxyConfig(prc); HtmlPage page = webClient.getPage("http://whatismyipaddress.com"); System.out.print(page.asText());
But if I replaced ip and port with localhost and 9050, then it does not work:
WebClient webClient = new WebClient(); ProxyConfig prc = new ProxyConfig("localhost", 9050, true); webClient.getOptions().setProxyConfig(prc); HtmlPage page = webClient.getPage("http://whatismyipaddress.com"); System.out.print(page.asText());
source share