Java eRRORServer为URL返回了HTTP响应代码:503:https://ipv4.google.com/
尝试为Java eRRORServer为URL返回了HTTP响应代码:503:https://ipv4.google.com/,java,bufferedreader,urlconnection,stringbuffer,Java,Bufferedreader,Urlconnection,Stringbuffer,尝试为https添加代理设置: import java.io.*; import java.net.URL; import java.net.URLConnection; public class Rough_Program { public static void main(String[] args) throws IOException { String inputLine = null; String contant = null; System.se
https
添加代理设置:
import java.io.*;
import java.net.URL;
import java.net.URLConnection;
public class Rough_Program
{
public static void main(String[] args) throws IOException
{
String inputLine = null;
String contant = null;
System.setProperty("java.net.useSystemProxies", "true");
System.setProperty("http.proxyHost", "10.10.10.1");
System.setProperty("http.proxyPort", "3128");
URL oracle = new URL("https://www.google.co.in/search?q=Old%20Trafford");
StringBuffer str1 = new StringBuffer();
URLConnection yc = oracle.openConnection();
yc.addRequestProperty("User-Agent", "Mozilla/4.76");
BufferedReader in = new BufferedReader(new InputStreamReader(
yc.getInputStream()));
while ((inputLine = in.readLine()) != null) {
str1.append(inputLine);
}
contant = str1.toString();
System.out.println(contant);
}
}
代码在其他url上工作,但在www.google.com上未命中。我想从谷歌那里拿到地址和电话。但它显示错误503。请帮助我。请查看503的删除以及如何修复。@jane我检查了你的共享链接,这没有帮助。谷歌网站在浏览器中运行良好。但是使用java会显示错误。谢谢回复。。我已尝试按照您的方式设置属性,但发生了相同的错误。
System.setProperty("https.proxyHost", "10.10.10.1");
System.setProperty("https.proxyPort", "3128");