4

我想将 HtmlUnit 与 Tor 一起使用。但是我无法使用 HtmlUnit 连接到 Tor(我正在运行 Tor Browser Bundle)。我在 TOR 文档中读到,我可以通过 localhost:9050 上的 socks 代理将 Tor 与其他应用程序一起使用。

我可以使用以下代码连接到在 google 上找到的普通代理:

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());

但是,如果我用 localhost 和 9050 替换 ip 和端口,则它不起作用:

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

1 回答 1

2

发现问题:端口号是 9150,而不是 9050。不知道他们为什么在文档中说 9050。

于 2013-03-19T18:10:53.073 回答