JAVA:通过代理响应的ip错误
有此程序:JAVA:通过代理响应的ip错误,java,url,proxy,ip,response,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:/
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)。我做错了什么 所以,问题在于公共代理巫婆不会隐藏您的请求信息。我们需要做的就是通过匿名代理发送请求 “在控制台中获取ip”是什么意思?当您在浏览器中访问该URL时,结果是什么?“在控制台中获取ip”是指我获取的响应类似于{“ip”:“my.local.ip.address”}与在浏览器中相同