【发布时间】:2015-03-22 02:59:31
【问题描述】:
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。请帮助我。
-
请参阅http://www.checkupdown.com/status/E503.html 了解 503 的说明以及如何修复它。
-
@jane 我检查了您的共享链接,它没有帮助。谷歌网站在浏览器中运行良好。但使用 java 它显示错误。
标签: java bufferedreader urlconnection stringbuffer