eRRORServer返回HTTP响应代码:503为URL:https://ipv4.google.com/

时间:2015-01-23 05:36:15

标签: java bufferedreader urlconnection stringbuffer

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);
  }
}

1 个答案:

答案 0 :(得分:0)

尝试为https添加代理设置:

System.setProperty("https.proxyHost", "10.10.10.1");
System.setProperty("https.proxyPort", "3128");