您知道我该怎么做才能检查WebBrowser中的代理是否正常工作?
答案 0 :(得分:1)
好吧,如果代理不存在,您将收到错误:
WebClient webClient = new WebClient(BrowserVersion.INTERNET_EXPLORER_8, "localhost", 8080);
HtmlPage page = webClient.getPage("http://htmlunit.sf.net");
System.out.println(page.asText());
org.apache.http.conn.HttpHostConnectException:
与http://localhost:8080的连接 拒绝 at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:127) 在org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:147)