HTMLUnit how to check if proxy is working properly
Do you know 开发者_开发技巧what can I do to check if proxy in WebBrowser is working properly?
Well, if the proxy does not exist, you will have an error:
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:
Connection to http://localhost:8080 refused at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:127) at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:147)
- If the proxy misbehaves, you will have a different page than what you expected
精彩评论