Proxy Jsoup集合代理

Proxy Jsoup集合代理,proxy,jsoup,Proxy,Jsoup,我正试图通过代理使用JSoup。当我只使用一个新的代理时,它工作得很好,但当我更改一个好的IP时,即107.165.33.12:3128->106.165.33.12:3128,它不应该工作,因为IP不是现有的代理。但它仍然只能用我自己的IP地址获取页面 针对这个问题我能做些什么,我想在代理不工作时得到某种错误 useProxy.java public class useProxy { public static void main(String[] args) throws IOEx

我正试图通过代理使用JSoup。当我只使用一个新的代理时,它工作得很好,但当我更改一个好的IP时,即107.165.33.12:3128->106.165.33.12:3128,它不应该工作,因为IP不是现有的代理。但它仍然只能用我自己的IP地址获取页面

针对这个问题我能做些什么,我想在代理不工作时得到某种错误

useProxy.java

public class useProxy {

    public static void main(String[] args) throws IOException {

        System.setProperty("http.proxyHost", "107.165.33.12");
        System.setProperty("http.proxyPort", "3128");
        Document doc = Jsoup.connect("http://www.toolsvoid.com/what-is-my-ip-address") //http://goldenpirates.org/proxy/azenv.php
                            .ignoreContentType(true)
                            .userAgent("Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0")  
                            .referrer("http://www.google.nl/")  
                            .timeout(12000) 
                            .followRedirects(true)
                            .header("Accept-Language", "en")
                            .header("Accept-Encoding","gzip,deflate,sdch")
                            .get();

        String iP = doc.select("table.list").select("strong").first().text(); //get used IP.
        String info = doc.select("textarea").text(); //get used IP.


        System.out.println("IP-Adres: " + iP);
        System.out.println("Info: \n" + info);
    }

}

你可能会喜欢这样做

    final String authUser = "USERNAME";
    final String authPassword = "PASSWORD";



    Authenticator.setDefault(
                   new Authenticator() {
                      public PasswordAuthentication getPasswordAuthentication() {
                         return new PasswordAuthentication(
                               authUser, authPassword.toCharArray());
                      }
                   }
                );

    ..

    System.setProperty("http.proxyHost", "192.168.5.1");
    System.setProperty("http.proxyPort", "1080");
    ..