How to use HtmlUnit with Tor?

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()); 
+4
source share
1 answer

Problem detected: port number is 9150, not 9050. I don’t know why they say 9050 in the documentation.

+2
source

All Articles