开发者

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?


  1. 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)

  1. If the proxy misbehaves, you will have a different page than what you expected
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜