JAVA:通过代理

时间:2016-03-31 11:21:37

标签: java url proxy ip response

有这个程序:

public static void main(String[] args) {
    System.setProperty("http.proxyHost", "177.40.136.238");
    System.setProperty("http.proxyPort", "8080");

    // Next connection will be through proxy.
    try {
        URL oracle = new URL("http://ip.jsontest.com/");
        while (true) {
            URLConnection yc = oracle.openConnection();
            BufferedReader in = new BufferedReader(new InputStreamReader(
                    yc.getInputStream()));
            String inputLine;
            while ((inputLine = in.readLine()) != null)
                System.out.println(inputLine);
            in.close();
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

    // Now, let's 'unset' the proxy.
    System.clearProperty("http.proxyHost");
}

当我在控制台中获取ip时,它不像设置代理的IP(它是我本地站的IP)。我做错了什么?

1 个答案:

答案 0 :(得分:0)

所以,问题在于公共代理巫婆并没有隐藏您的请求信息。我们需要做的 - 通过匿名代理发送我们的请求。